


Let 'S' is 121. Then the nearest integers are 111 and 131 which are palindrome. Both have the same absolute difference but 111 is smaller. Hence 111 is the answer.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first and the only line of each case contains a single string ‘S’ denoting the integer.
For each test case, return the closest palindrome number from 'S'.
The output of each test case will be printed in a separate line.
You are not required to print the expected output, it has already been taken care of. Just implement the function.
1 <= T <= 50
0 <= No of digits in ‘S’ <= 18
Time Limit: 1 sec
Explanation: The main idea is for a given number find a palindrome number just greater and smaller than a given number. The one with minimum absolute value is the answer.
Algorithm :