Limits 1s, 512 MB

Sajeeb and Shoikot are two friends. Both are love mathematics. Sajeeb has a fascination with ZERO. They are discussing a math problem. MM is equal to AA to the power BB multiply CC to the power DD multiply E to the power FF. In mathematical equation:

M = A^B x C^D x E^F

Now, You are given six integers (AA, BB, CC, DD, EE, FF). You have to print the trailing zeros of MM.

Input

The first line contains one integer tt (1t100001 \le t \le 10000). Each of the next tt lines contains six integers: AA, BB, CC, DD, EE and FF (0A,B,C,D,E,F10000000 \le A, B, C, D, E, F \le 1000000).

Output

For each test case, print the case number as "Case X: " followed by the number of trailing zeros of MM.

Sample

InputOutput
2
2 3 4 2 5 1
2 1 6 2 8 2
Case 1: 1
Case 2: 0

Submit

Login to submit.

Statistics

90% Solution Ratio
steinumEarliest, Apr '21
ITisMAHMUDFastest, 0.0s
isratTLightest, 258 kB
steinumShortest, 539B
Toph uses cookies. By continuing you agree to our Cookie Policy.