#C1158. K-th Reversed Sum Sequence Element
K-th Reversed Sum Sequence Element
K-th Reversed Sum Sequence Element
You are given an initial non-negative integer \(X\) and a number \(K\). Start with \(X\) and perform the following operation exactly \(K\) times: reverse the decimal digits of \(X\) and add the resulting number to \(X\). The task is to compute the final value of \(X\) after these operations.
Formally, let \(reverse(X)\) denote the integer obtained by reversing the digits of \(X\). Then, the operation is defined as:
[
X \leftarrow X + reverse(X)
]
Apply this operation exactly \(K\) times starting from the given \(X\). If \(K = 0\), simply output \(X\).
Note: The reversal is done on the decimal representation of \(X\) (without any leading zeros considered after reversal).
inputFormat
The first line of input contains a single integer \(T\) (\(1 \leq T \leq 10^4\)), the number of test cases. Each of the following \(T\) lines contains two integers \(X\) and \(K\) separated by a space.
\(X\) is the starting integer and \(K\) is the number of iterations to perform the reversal addition operation.
outputFormat
For each test case, output a single line containing the final value of \(X\) after \(K\) operations.
## sample3
123 1
48 2
9 3
444
363
198
</p>