#C9825. Taco Number Sequence

    ID: 53961 Type: Default 1000ms 256MiB

Taco Number Sequence

Taco Number Sequence

You are given a special sequence defined as follows. The first element of the sequence is 1. To obtain the next element, add 2 to the current element. If the resulting number is greater than 9 (i.e. it has more than one digit), reverse its digits. Formally, let \(a_1=1\) and for \(n > 1\), define \(a_n\) as:

\(a_n=\text{reverse}(a_{n-1}+2)\) if \(a_{n-1}+2>9\) and otherwise \(a_n=a_{n-1}+2\). For example, the sequence starts as: 1, 3, 5, 7, 9, 11, 31, 33, 53, 55, ...

Your task is to compute the \(N\)-th element of this sequence for a given \(N\>.

inputFormat

Input is read from standard input (stdin). The first line contains a single integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains one integer \(N\), where \(N\) is the position in the sequence to compute.

For example:

3
1
5
10

outputFormat

For each test case, output the \(N\)-th element of the sequence on a separate line to standard output (stdout).

For the sample input above, the output should be:

1
9
55
## sample
3
1
5
10
1

9 55

</p>