#C10573. Digital Root - Single Digit Sum

    ID: 39793 Type: Default 1000ms 256MiB

Digital Root - Single Digit Sum

Digital Root - Single Digit Sum

Given a non-negative integer x, repeatedly sum its digits until the result has only one digit. This process is known as computing the digital root of x. For example, the digital root of 9875 is computed as follows:

(9875 \rightarrow 9+8+7+5=29) (29 \rightarrow 2+9=11) (11 \rightarrow 1+1=2)

Thus, the digital root (or single-digit sum) of 9875 is 2. You are required to handle multiple test cases.

Input Format: The first line contains a single integer T, the number of test cases. Then follow T lines each containing one non-negative integer x.

Constraints: x is a non-negative integer.

Output Format: For each test case, output the digital root of x on a new line.

inputFormat

The input is read from standard input (stdin). The first line contains an integer T, representing the number of test cases. Each of the next T lines contains a single integer x.

outputFormat

For each test case, print the digital root of x on a new line. The output is printed to standard output (stdout).## sample

3
9875
12345
0
2

6 0

</p>