


1) A palindrome is a word, number, phrase, or another sequence of characters that reads the same backward as forward, such as 'naman', 'abcba', '1234321', etc
2) The numerical value of the given string 'S' will be greater than 0.
3) A single-digit number is also considered as a palindrome.
4) Note that the length of the string 'S' is nothing but the number of digits in the number 'N'.
The first line of the input contains an integer 'T' denoting the number of test cases.
The first line of each test case contains an integer, denoting the number of digits in the number 'N' (i.e. the length of the string).
The second line of each test case contains the string 'S'.
The only line of output of each test case consists of the next greater palindromic number(as described in the problem statement) returned in the form of a string.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= len(S) <= 10^4
Time Limit : 1 sec
In this method, Before we start let us define what is the right half (or right part) and what is left half (or left part) in the string. There can be two cases based on the length of the string:
This number can also be represented as:
1234567= 1*10^6 + 2*10^5 + 3*10^4 + 4*10^3 + 5*10^2 + 6*10^1 + 7*10^0.
From this, we can derive a conclusion that the left part contains more significant digits (digits with greater place value) as compared to the right part.
So The algorithm for the problem would be as follows: