Next to Never

Geometric series have many important roles in mathematics. An infinite geometric series that has a positive integer as first term and whose general ratio is a non-negative rational number can be written as follows: ()()()() () pp2p3p4 a+a q +a q +a q +a q +...to∞ Here a is the first term of geometric series and p and q are non negative integer numbers. Infinite geometric series converges when the general ratio is less than 1 and diverges when the general ratio is greater than or equal to 1. In other words converging infinite geometric series has summation less than infinity. But for this problem, a converging geometric series is a series whose sum does not exceed a given value, as “less than infinity” does not indicate any specific value. We refer this given value as NEXT_TO_NEV ER in this problem. So given the value of NEXT_TO_NEV ER and a, () your job is to find out how many different fractions pq are there so that the series remain convergent (Summation not exceeding NEXT_TO_NEV ER). Input Input file contains less than 550 sets of inputs. The description for each set is given below: The input for each set is given in a single line. This line contains three integers NEXT_TO_NEVER (1000 ≤ NEXT_TO_NEVER ≤ 10000), a (1 ≤ a ≤ 5) and MAXV (20000 ≤ MAXV ≤ 100000). Meaning of NEXT_TO_NEVER and a is already given in the problem statement. The value MAXV indicates the maximum possible value of p and q. Note that the minimum possible value for p and q is 0 (zero) and 1 (One) respectively. Input is terminated by a line containing three zeroes. Output For each line of input produce one line of output. This line contains the serial of output followed by two integers s and t. The first integer s denotes how many different possible fractions pq , are there considering p and q are relative prime. The second integer t denotes how many different possible fractions pq are there considering p and q may or may not be relative primes. Look at the output for sample input for details. Sample Input 1000 1 20000 000 Sample Output Case 1: 121468930 199820000 ()