Given a palindromic number N in the form of string. The task is to find the smallest palindromic number greater than N using the same set of digits as in N.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains a number N as input.
For each test case, print the next higher palindromic number possible. If no such number can be formed then print "-1".
1<=|Number length |<=104
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.