#C10309. Next Palindromic Number

    ID: 39500 Type: Default 1000ms 256MiB

Next Palindromic Number

Next Palindromic Number

Given an integer x, the task is to find the smallest palindromic number that is greater than x. A palindromic number is one that remains the same when its digits are reversed. Mathematically, a number N is palindromic if \(N = \text{reverse}(N)\).

You will be given multiple test cases. For each test case, output the smallest palindrome strictly greater than the given integer.

inputFormat

The input is given via standard input (stdin) and has the following format:

T
x1
x2
...
xT

Here, T (an integer) is the number of test cases, and each subsequent line contains a single integer \(x_i\) for which you must compute the next palindromic number.

outputFormat

For each test case, output the smallest palindromic number greater than the given \(x_i\) on a separate line to standard output (stdout).

## sample
3
6
123
808
7

131 818

</p>