#K67192. Largest Even Number
Largest Even Number
Largest Even Number
Alice is playing a game where she is given a positive integer x and she must remove exactly one digit from it in order to form the largest possible even number. If it is impossible to obtain an even number by removing a single digit, then she must retain the original number.
Formally, given a number \(x\) with at least two digits, remove exactly one digit to form a new number \(y\). Among all choices of \(y\) that are even, choose the largest one. If no such \(y\) exists, output \(x\) unchanged.
The input has multiple test cases. For each test case, the input consists of a single integer \(x\) satisfying \(10 \le x \le 10^9\). The first line of the input is an integer \(t\), the number of test cases.
Input Format: The first line contains the integer \(t\) (\(1 \le t \le 1000\)), followed by \(t\) lines each containing an integer \(x\).
Output Format: For each test case, output the largest even number that can be obtained by removing exactly one digit, or the original number if none of the removals results in an even number.
inputFormat
The first line contains an integer \(t\) (the number of test cases). Each of the following \(t\) lines contains a single integer \(x\) (\(10 \le x \le 10^9\)).
outputFormat
For each test case, print the result on a new line — the largest possible even number obtained by removing exactly one digit. If no even number can be obtained, print the original number.
## sample3
123
13579
2468
12
13579
468
</p>