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
shreyasz_07:
20201123 17:45:18
I'm getting tle Last edit: 20201123 17:47:56 

xander_70:
20201116 09:57:10
How could I fix my TLE problem 

shreyas_07:
20201115 09:28:17
If you're getting wrong ans use these tc's:


rajutsav1234:
20201106 19:44:38
i have been writing code in C and it works perfectly on Ideone and is giving correct output, but here I am getting error. It is showing wrong answer. Please help me... 

bong0s_guy01:
20201025 06:53:04
Hey, does anyone know where can I get the input tests cuz I've tried the most optimal code I could but still exceed time limit, so I just want to k now where can I get the test to know how to optimize it 

vcillusion:
20201018 13:00:47
In C#, I tried with BigInteger and without it, the result is TLE. Can it be a limitation for C#? Please fine my solution below


coder582:
20201008 09:16:28
All the peeps who say that there solution is correct but they are getting WA, trust me, your solution is wrong.


koogoo:
20200909 19:26:45
be careful with "K is not more than 10^6 digits", so you can't use long long type to store the number.


arya1111:
20200825 21:13:02
I'm getting SIGABRT,even though it is working successfully on ideone. 

nullie:
20200820 10:19:07
If you get "wrong answer", try to make you own comprehensive test suite: iterate from 0 to some large n, if n is a palindrome, your function must return it as a result for all the numbers from previous palindrome to n. 
Added by:  adrian 
Date:  20040501 
Time limit:  2s9s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS PERL6 