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
kmkhan_014:
20190816 13:12:56
ye question hatao, har company yehi puchti hai Last edit: 20190824 12:59:57 

mriow:
20190813 09:35:32
It works fine with python3, BUT do not convert ever from string to int (do not use int() on python) since it is a HUGE slow down of the running time, giving even a TLE error.


thirumalai:
20190813 08:39:36
Does this work in python?


hit7sh:
20190809 17:48:01
Works perfectly in Bluej and shows compilation error in here. Like wtf!? 

bnnj:
20190805 12:49:50
I think there might be something wrong with this problem / its judge.


bnnj:
20190801 16:35:34
Hi,


naman_mawandia:
20190713 08:27:17
1>2


tokyoghoul1993:
20190708 16:57:29
Before writing code, try to think of as many tricky test cases to cover all cases.


mr_quan1998:
20190705 18:53:03
it take me 5h


beingbmc:
20190703 21:45:19
https://stackoverflow.com/questions/7934519/abetteralgorithmtofindthenextpalindromeofanumberstring/8187788#8187788

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