#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 11: If the score is a multiple of 55, the player gets a bonus of MM.
  • Bonus 22: If every digit of the score is the same, the player gets a bonus of NN.

Note that if the score satisfies both conditions, the player gets a bonus of M+NM + N. :)

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 M=3M = 3, N=8N = 8, and the initial score is 5555. The score 5555 satisfies both conditions and the player gets a bonus of 3+8=113+8 = 11. Then the score increases to 6666, which leads another bonus of 88. When it reaches 7474, no more bonus is available. So the final score is 7474.

Assume that XNJ can get any initial score between 11 and 1000010000, 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 TT (T15T \leq 15) indicating the number of test cases.

For each test case there are two integers MM and NN (1M,N501 \leq M, N \leq 50) 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 11. 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 6464-bit int bound, i.e. the result is smaller than 2632^{63}.

Samples

2
24 50
10 1
Case #1: 10049
Case #2: INF

Resources

10th UESTC Programming Contest Preliminary