PALIN  The Next Palindrome
A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
Input
The first line contains integer t, the number of test cases. Integers K are given in the next t lines.
Output
For each K, output the smallest palindrome larger than K.
Example
Input: 2 808 2133 Output: 818 2222
Warning: large Input/Output data, be careful with certain languages
hide comments
surfeyone:
20200524 00:26:44
0 > 1


kauai68:
20200517 16:48:29
There are no leading zeros. 

wahidmshafin:
20200516 21:00:15
Try for these test cases


kauai68:
20200510 18:28:28
I've got AC and I don't think that the implementation is difficult. Nice C++ code needs less than 80 lines of code. Last edit: 20200510 18:29:45 

khoaph:
20200510 03:34:49
Thanks @trulyness for the extra test cases


manishsaini4u:
20200509 05:30:08
can anyone explain what problem says? 

meher_24:
20200507 16:17:01
do i just increment the input by one and check if its a palindrome or is there a better and a faster method?


hritik_1105:
20200507 06:23:05
Its logic is easy but implementation is hard.


bernard_mocko1:
20200504 01:09:54
When they say, that elements are not more than 1000000 digits, they are not joking, my char array in C was one element to short Last edit: 20200504 01:17:10 

fawad:
20200425 09:54:46
guys, there is space character after input in every line, just take care of it

Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 