You are given a function $f$ which is defined as:
int f(n) {
while (n >= 10) {
n = sod(n);
}
return n;
}
$sod(n)$ indicates the sum of digits of n. So, f(7689) = 3 (7689 => 30 => 3).
Input
Input starts with an integer T (≤ 50), denoting the number of test cases.
Each case starts with two big integers a b (0 ≤ a, b < 1050,000, a + b > 0).
Output
For each case, print the case number and $f(a^b)$.
Sample
Sample Input | Sample Output |
---|---|
4 2 5 7 2 8 1 1 1234567890123456789012345 | Case 1: 5 Case 2: 4 Case 3: 8 Case 4: 1 |
Notes
Dataset is huge, use faster I/O methods.