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
Vaibhav Malik:
20151006 21:00:24
AC in One GO . . . . . 

ankitch6:
20151005 23:21:54
ac in first attempt....:)


farmers_rice:
20151003 02:42:47
I am getting a runtime error but the program works fine on my computer and in ideone 

dungen_master:
20150930 15:42:12
getting error time limit exceed!!


mihirs745:
20150926 13:02:55
Very good question but in my case it shows time limit exceeded.Some one please help me and check my code its in C


nguyễn vãn lâm:
20150923 18:49:02
the only once, accepted!.. Last edit: 20150923 19:29:01 

nishaagg:
20150913 18:48:20
I am also getting NZEC error... 

Dushyant Singh:
20150912 14:03:43
@almas  because we have to find next palindrome. 2112<2133 and 2133<2222. 

Almas:
20150912 11:54:31
For the second case why output can't 2112 which is less than 2222? 

tiwariayan:
20150911 17:38:31
tried like some 500 test cases

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