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
gourgan:
20200229 11:15:10
. Last edit: 20200229 11:16:31 

atulav:
20200112 12:10:03
Finally did it after years. 

sayan_244:
20191219 07:11:03
LOL! can the input number have leading zeroes??


ashwanitr001:
20191201 12:14:56
For people getting WA try test cases like 0,99,199


harindra2002:
20191123 14:10:06
should we input the values given in the example or leave the input to the computer? 

aneeshs_7901:
20191119 16:19:14
its giving wrong answer everytime i submit.its working fine and the output is correct in ideone 

binit_54:
20191015 06:22:42
can someone give me some idea on how to store the strings in this problem for later access when all the input has been finished? 

pranay19263:
20191010 08:19:56
giving runtime error all the time


suryansh_singh:
20191006 18:31:42
i written my code without using nested loop ,then also it raising ' time exceeded limit'


saurabh2012:
20191006 16:17:23
Last edit: 20191006 16:21:22 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 