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
ashwini_571:
20190115 21:26:34
Last edit: 20190115 21:26:56 

squirrelli:
20190103 14:02:41
If input is 010,000, isn't the output 10,001? 

sehgal_divij:
20190102 13:21:19
runs on my machine but fails here.


nitin_uniyal:
20181223 05:14:36
running time 0.56 s.


spyhawk_74:
20181222 12:59:57
Finally ACed in 9th attempt.


Maneesh Sharma:
20181218 10:11:49
If k is 999, should the output be 1001 ? Last edit: 20181218 10:12:34 

fuyanghua:
20181214 09:53:21
I have run over 10^20 times on my computer and it only cost 2s.However,I got TIME LIMITE EXCEEDED when submit every time. Who can tell me why? Last edit: 20181214 10:13:03 

dhananjay_gore:
20181212 07:25:17
I'm getting runtime error NZEC in this problem while submitting


aashish_a2z:
20181210 22:54:24
This is a nice problem.....Try to consider all the cases........Not a easy problem so don't worry it will take some time to solve...try to optimize your code....


sudesh12345:
20181208 09:39:37
Anyone please help me.

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