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
ANKIT KUMAR CODOPEDIAC:
20140212 06:51:43
can u plz tell me at which test case this is giving wrong ans?


cegprakash:
20140115 18:57:58
The problem's worth will increase after rejudge! 

Mitch Schwartz:
20140115 16:16:38
@Ćukasz Kuszner: Thanks! Moved back to classical.


kuszi:
20140115 15:23:59
Tests are a little stronger, what about moving it back to classical? 

Mitch Schwartz:
20140115 15:17:31
Moved to tutorial. 

Subhasish Saha:
20140115 15:17:31
Many people have commented but still test cases have not been corrected!!!


cegprakash:
20140115 15:17:31
Martijn Muijsers: true that


Aravind Sagar:
20140115 15:17:31
@shweta choudhary The problem is that the input number can have 1000000 digits, so int and long long won't work. Try to store it as a string and think of a different approach. 

aqua:
20140115 15:17:31
checked all cases still getting WA ...can anyone help? i am coding in C... http://ideone.com/G3Ept4 even getting correct output here Last edit: 20131218 21:07:23 

amin ababneh:
20140115 15:17:31
omg!!!! same code i wrote in java and c++

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