## 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

 < Previous 1 2 3 4 5 6 7 8 9 10 11 Next > puppetmaster: 2024-06-25 10:08:00 was getting wrong answer forever @shreyas_07 tcs saved me temurjon_01: 2024-03-07 09:55:53 what a fuck is that spoj find another compiler i did anything right and again "WRONG ANSWER". rayhanulislam: 2023-12-15 17:08:01 how much test case? dwind11: 2023-11-06 09:18:11 gg sleepyslash: 2023-07-02 12:02:44 my code is all fine and working very well in my compiler the same file giving a runtime error in spoj judge why ??? my code : can anyone tell whats wrong [Simes]: this is not the place for code review, use the forum. Last edit: 2023-07-02 12:05:41 jmdalida11: 2023-02-16 12:17:09 I solved it using rust <3 fjkexgnffhwihp: 2022-06-20 17:09:50 Why is the implementation difficulty so high? I found it to be pretty easy in both concept and implementation in CPP14 paintbucket7: 2022-04-23 21:04:52 If you're getting SIGABRT then it means that you're probably converting the given string to int so you must not do that. You must solve the problem in the string itself as the input is too large. Moreover, if you're getting the Wrong Answer then you should use the test cases provided by @shreyas_07 in this comment section. They're around 1-2 pages behind the current page. They would help you debug your program. mmani0831: 2022-02-28 17:43:28 I got right answers for sample and custom test case. But still i am getting WA. zinfx_09: 2022-02-23 03:19:25 10^6 digits not 10^6 int...

 Added by: adrian Date: 2004-05-01 Time limit: 2s-9s Source limit: 50000B Memory limit: 1536MB Cluster: Cube (Intel G860) Languages: All except: NODEJS PERL6

#### Problem's scores 1 vote

##### Concept difficulty
Concept difficulty 37%
##### Implementation difficulty
Implementation difficulty 50%
468 16