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
dadhich_01:
20180902 17:55:14
naruto17 read question clearly 

eng_hardik:
20180902 07:44:57
A great problem with a variety of test cases , so before careful about all the possibilities. 

gvsharma:
20180828 07:10:21
getting time exceeded..


rajatsahay:
20180825 09:27:05
it says time limit exceeded..ran it on ideone.com and total time taken was 0.04s 

naruto17:
20180819 22:02:21
for run time errors ;


nobody550:
20180804 21:17:51
Check for '9'


aquib_ansari:
20180715 17:44:49
Do we need to consider ve numbers as well? 

shivansh306:
20180715 12:39:04
Run time error in python3 I am defining a function for solving the problem 

rogu_auto:
20180713 16:25:02
pay attention to "K of not more than 1000000 digits"! u can't use a numeric variable to save K, u need a string variable! 

phuongnguyen96:
20180711 11:19:55
runtime error. i don't understand, with java!!

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