#C1222. Digital Root Transformation

    ID: 41623 Type: Default 1000ms 256MiB

Digital Root Transformation

Digital Root Transformation

You are given a list of non-negative integers. For each integer, repeatedly sum its digits until the result is a single digit. This final single digit is called the digital root of the number. In mathematical terms, for a positive integer \(n\), the digital root \(dr(n)\) can be defined as:

\( dr(n) = 1 + ((n - 1) \mod 9) \quad (n > 0) \) and \( dr(0) = 0 \).

Implement a program which reads the input from stdin and outputs the digital root for each integer separated by a space.

inputFormat

The first line contains a single integer \(T\) indicating the number of integers in the list. The second line contains \(T\) space-separated non-negative integers \(a_1, a_2, \dots, a_T\).

outputFormat

Output a single line with \(T\) space-separated integers, where the \(i\)-th integer is the digital root of \(a_i\).

## sample
9
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9