Problem E
Coffee lids

"Coffee should be black as hell, strong as death, and as sweet as love."
Turkish proverb

Coffee shops usually have large stacks of lids. You get your cup of coffee, pick the top lid from the stack and put it on your cup. However, the lids in the stack are notorious for sticking to each other, so when you pick up the top lid, several more lids might come off the stack with it. Most people then try to pull off the top lid by force, but that is difficult to do because it requires two hands, and your other hand is holding the coffee cup. Instead, you decide to do something different. When two or more lids stick together, you will simply try to pick up another lid from the top of the stack, and you will continue doing this until the top lid that you pick up does not stick to the lid below it.

You have an infinite stack of lids, and you know that the probability of any two adjacent lids in the stack sticking to each other is p. What is the expected number of lids that you have to take off the stack until you get a single lid?

The first line of input gives the number of cases, N. N test cases follow. Each one starts with a line containing p (0<=p<1) in the form of a fraction. Its denominator will not exceed 2000000000.

For each test case, output one line containing "Case #x:" followed by the expected number of lids you need to pick up, as a fraction in lowest terms.

Sample Input Sample Output
Case #1: 4/1
Case #2: 1/1

Problemsetter: Igor Naverniouk