Time Limit: 1 second(s) | Memory Limit: 32 MB |
Vinci is a little boy and is very creative. One day his teacher asked him to write all the Palindromic numbers from 1 to 1000. He became very frustrated because there is nothing creative in the task. Observing his expression, the teacher replied, "All right then, you want hard stuff, you got it." Then he asks Vinci to write a palindromic number which is greater than the given number. A number is called palindromic when its digits are same from both sides. For example: 1223221, 121, 232 are palindromic numbers but 122, 211, 332 are not. As there can be multiple solutions, Vinci has to find the number which is as small as possible.
Input starts with an integer T (≤ 30), denoting the number of test cases.
Each case starts with a line containing a positive integer. This integer can be huge and can contain up to 10^{5} digits.
For each case, print the case number and the minimum possible palindromic number which is greater than the given number.
Sample Input |
Output for Sample Input |
5 121 1 1332331 11 1121 |
Case 1: 131 Case 2: 2 Case 3: 1333331 Case 4: 22 Case 5: 1221 |
Dataset is huge, use faster I/O methods.
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |