1419 - Function

Time Limit: 10s Memory Limit: 128MB

Submissions: 379 Solved: 201
Description

Believe me, short decription doesn’t always mean hard problem. Like the following one:

Let’s define two simple function D(x) and F(x)

D(x) is the digit sum of the number x: D(1) = 1, D(1203) = 6, D(99) = 18…

F(x) = x if x < 10

F(x) = F(D(x)) otherwise.

Input

There are multiple cases.

The first line is an integer T representing the number of test cases.

The following T lines each line representing a test case. For each case there are exactly one line containing a single number X(0 < X < 1000000000).

Output

For each test case, output a line containing the answer in the following format:

Case #K: T

K is the case number starting frome 1, and T equal to F(X).

Sample Input
2
3
12
Sample Output
Case #1: 3
Case #2: 3
Hint
Source