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
Utkarsh:
20140826 15:39:54
What should be the output in case of single digit integers?


Nazib Sorathiya:
20140824 15:13:05
Time Limit Exceeded !!!!!!!


GURUPREET SINGH:
20140822 20:39:44
do we need to consider 0 as an input??


Hidenori:
20140730 00:50:18
It's very easy to write bruteforce solution, so it was really easy to test! 

LeppyR64:
20140727 17:31:11
Read the problem statement carefully there have been many posts on the forum with people missing the same detail:


Nakul Mohan:
20140726 20:52:06
nice problem...AC finally :)


Zishan Ahmad:
20140721 16:28:30
what is the upper limit of t ? 

Yevgen Yampolskiy:
20140713 06:38:05
WARNING: last line does not have terminating '\n'. If you implement your own I/O library then you may run into an issue (as I did) Last edit: 20140713 17:43:42 

Wasim Thabraze:
20140705 12:36:16
Huh! Finally AC after a 24hr struggle! Last edit: 20140706 05:59:45 

Mitch Schwartz:
20140626 21:40:34
@ankush: There is no such feature. (This is mentioned at http://www.spoj.com/tutorials/USERS/#submit  "Input and output data used by SPOJ judge to decide whether your solution is correct or not are set by problemsetter (person who adds problems) and are hidden. Many of problems has tricky test data so the ability to form you own and comprehensive test cases is very useful.") 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 