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
the_imp:
20150114 20:43:19
http://ideone.com/7ejK6Y


Ani:
20150114 14:05:49
Keep the following test cases in mind:


Kaushik Nath:
20150113 17:38:40
i am taking input through strings


Rajat:
20150112 19:48:47
extremely good question. :) 

hanu_man:
20150108 15:28:22
it is all about nines.... 

praveen anuranjan:
20150108 10:13:59
http://ideone.com/mA5RqI every answer is coming true and still giving WA someone plzzz help Last edit: 20150109 10:58:53 

Trailblazer:
20150107 14:58:52
Does inputs are not separated by '\n' ?


Novice Whistler:
20150107 04:48:19
@Punit, you have taken the data type of inputs as long. This will not be able to hold a 10000 digit number. So, the test cases beyond the "capacity" of long will not pass.Try using string for this. Last edit: 20150107 04:49:22 

Ankit Srivastava:
20150103 08:11:38
Please help point where I am hitting TLE  http://ideone.com/sy5S0c 

Punit Bhatt:
20150102 11:33:13
Tried solving this problem. Got right answers in all cases but am getting wrong answer here in spoj. Please help me out

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