#C4071. Next Palindromic Number
Next Palindromic Number
Next Palindromic Number
Given an integer, your task is to find the smallest palindromic number strictly greater than the given integer. A palindromic number is a number that remains the same when its digits are reversed. For example, when the input number is 123, the smallest palindromic number greater than 123 is 131.
You will be given multiple test cases. For each test case, compute and print the corresponding next palindromic number.
The mathematical formulation can be described as: Find the smallest number \( p \) such that \( p > n \) and \( p = \text{reverse}(p) \).
inputFormat
The first line of input contains a single integer \( T \) representing the number of test cases. Each of the following \( T \) lines contains one integer \( n \) for which you need to find the next palindromic number.
For example:
3 123 99 678
outputFormat
For each test case, output the smallest palindromic number that is strictly greater than the input number.
Each output should be printed on a new line.
For example, given the sample input above, the output should be:
131 101 686## sample
3
123
99
678
131
101
686
</p>