题目描述

(Reduced Digit Sum) The reduced digit sum of a number is the sum of the digits. If the sum of the digits is greater than nine then the process is repeated. For example, the sum of the digits for 567 is 5+6+7=18 and the sum of the digits for 18 is 9, so the digit sum of 567 is 9.


输入格式

The input consists of n (0<n<100) lines.
Each line consists of the integer (ranges from 0 to 10^9109).
The last line of input consists of Int(-1).


输出格式

Output the reduced digit sum of the input number.


样例数据

输入

0
1
123
123456
-1

输出

0
1
6
3

备注


操作

评测记录

优秀代码

信息

时间限制: 1s
内存限制: 128MB
评测模式: Normal

题解