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
Dario Pavlovic:
20141103 16:48:14
AC. Number 50 :) Last edit: 20141103 16:57:42 

Samuel:
20141103 00:18:32
NZEC with Java when closing the streams


Sergey Skupoy:
20141026 10:01:04
NZEC in Haskell. Something is wrong with EOL. Last edit: 20141031 23:19:29 

karan:
20141025 10:54:26
finally :') :') this gave a strong feel :D :') 

huangqihy:
20141023 06:55:11
2 is one digit and 20 is two and 1,000 is four,so 1000000 digits means the number has 1000000 number in it 

Thiefds:
20141022 21:01:11
What means "For a given positive integer K of not more than 1000000 digits"?


Suryakalyan Rani:
20141010 07:51:43
Completely missed the part "K of not more than 1000000 digits" 

Govinda:
20141008 08:50:12
in java StringBuffer has reverse() ,so reverse and compare them Last edit: 20141008 08:50:30 

Ramon:
20141006 00:48:18
I need some help, please. My code runs fine in my machine but gets a WA. Can someone post a good set of test cases, please? 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 