#K9796. Next Palindrome Finder

    ID: 39109 Type: Default 1000ms 256MiB

Next Palindrome Finder

Next Palindrome Finder

Given an integer N, your task is to find the smallest palindrome greater than N.

A number is a palindrome if it reads the same forwards and backwards. For example, 121 and 12321 are palindromes, whereas 123 and 12331 are not.

The input begins with an integer T denoting the number of test cases, followed by T lines each containing an integer N. Your program should output the smallest palindrome greater than N for each test case on a new line.

inputFormat

The first line contains an integer T representing the number of test cases. The next T lines each contain a single integer N.

outputFormat

For each test case, output a single line containing the smallest palindrome greater than N.

## sample
3
123
808
999
131

818 1001

</p>