Statement : Sum of Digits (and Again)
For a positive (strictly greater than
- Initially, the string is empty.
- Append to it (on the right) the decimal representation of the number
without leading zeros. - If
, the process ends. Otherwise, replace with the sum of the digits of and go back to step 2.
Examples:
is75123. is303. is9.
You are given a string
The first line contains one integer
Each test case consists of one string containing
Additional constraints on the input:
- The sum of lengths of
over all test cases does not exceed . - It is possible to rearrange the digits in
to obtain for some positive integer .
For each test case, output one string —
Input
5
12735
1
011
99999299999999299959999999999999
4621467
Output
75123
1
101
99999999999999999999999999992529
6442167