#P5051. Fraction

Fraction

Problem Description

Given a number n, and a geometric progression ai = b * qi, i ≥ 0, what is the fraction of the elements of that progression with decimal notation that has the decimal notation of n as prefix ?

More formally, if ci out of the first i elements of the progression start with n in decimal notation, you need to find the limit. It is guaranteed that the limit always exists.

For example, n = 7, b = 1, q = 2. About 5.799% of all powers of two start with 7. (the smallest one is 246 = 70368744177664)

Input

The first line of the input is T (1 ≤ T ≤ 100), which stands for the number of test cases you need to solve.

Each case contains three integers n,b and q. (1 ≤ n, b, q ≤ 1000)

Output

For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then output one floating number – the sought fraction. Round your answer to the 5th decimal place.

2 7 1 2 1 1 1
Case #1: 0.05799 Case #2: 1.00000