#Lutece0560. Fruit Ninja
Fruit Ninja
Migrated from Lutece 560 Fruit Ninja
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
In Fruit Ninja, the player slices fruit with a blade controlled via a tablet. As the fruit is thrown onto the screen, the player swipes their finger across the screen to create a slicing motion, attempting to slice the fruit in half.
--- Wikipedia
Fruit Ninja is a very popular game and XNJ likes it very much. After the game player can get a bonus based on his/her score.
- Bonus : If the score is a multiple of , the player gets a bonus of .
- Bonus : If every digit of the score is the same, the player gets a bonus of .
Note that if the score satisfies both conditions, the player gets a bonus of . :)
One day when playing on it, XNJ came out an idea: if he can keep getting bonus until satisfying neither conditions, how much he can get? For example, given , , and the initial score is . The score satisfies both conditions and the player gets a bonus of . Then the score increases to , which leads another bonus of . When it reaches , no more bonus is available. So the final score is .
Assume that XNJ can get any initial score between and , he wants to know what's the maximum final score he can get?
Input
There are multiple test cases. The first line of the input will be an integer () indicating the number of test cases.
For each test case there are two integers and () in a single line.
Output
For each test case, print Case #t:
first, in which t is the number of the test case starting from . Then output the maximum final score he can get. If it can be added endless, output INF
. The data ensures that result is in a signed -bit int bound, i.e. the result is smaller than .
Samples
2
24 50
10 1
Case #1: 10049
Case #2: INF
Resources
10th UESTC Programming Contest Preliminary