Loading [MathJax]/jax/output/HTML-CSS/jax.js

Trailing Zeroes (II)

1 seconds
64 MB
Medium
LOJ-1090 Udebug Debug
English

Find the number of trailing zeroes for the following function:

(nr)×pq

where n, r, p, q are given as Input.

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case contains four integers: n, r, p, q (1 ≤ n, r, p, q ≤ 106, r ≤ n).

Output

For each test case, print the case number and the number of trailing zeroes.

Sample

Sample Input Sample Output

2 10 4 1 1 100 5 40 5

Case 1: 1 Case 2: 6

Notes

For case 1, n = 10, r = 4, p = 1, q = 1, then the result is 210 and number of trailing zeroes is 1.