New Year's Eve Wine Pyramid

Simulate B bottles poured into the top glass of a wine pyramid where overflow splits into three glasses below and report the amount in glass N on level L.

Medium6SimulationDynamic programmingNo attempts yetTime limit5sMemory limit512 MB

Problem

At a New Year's Eve party the wine glasses are stacked into a pyramid. The top level holds one glass, the second level holds three, the third holds six, and the fourth holds ten.

Each glass is identified by two numbers, LL and NN. LL is the level the glass sits on and NN is its number within that level. The glasses on one level form a triangle. They are numbered from the top row downwards, and from left to right within each row.

Level 1:
    1

Level 2:
    1
 2     3

Level 3:
      1
   2     3
4     5     6

Level 4:
         1
      2     3
   4     5     6
7     8     9     10

Write a glass on level LL as row rr, position cc inside that row, where 1crL1 \le c \le r \le L. Its number is then N=r(r1)/2+cN = r(r-1)/2 + c.

Each glass holds 250ml of wine. The bartender opens bottles of 750ml each and pours into the top glass (L=1L = 1, N=1N = 1).

Once a glass is full, the wine that overflows splits equally among the three glasses on the level below that touch it, and none of it spills outside. Wine never flows into a neighbour on the same level, and it never skips a level. When the glass (r,c)(r, c) on level LL overflows, the wine runs into the glasses (r,c)(r, c), (r+1,c)(r+1, c) and (r+1,c+1)(r+1, c+1) on level L+1L+1. For example, when the glass with L=2L = 2 and N=2N = 2 overflows, the wine runs into glasses 2, 4 and 5 on level 3.

After the bartender has poured all BB bottles, report how much wine in ml sits in glass number NN on level LL.

Input

The first line contains the number of test cases TT. Each of the next TT lines holds one test case with three integers BB, LL and NN separated by spaces. BB is the number of bottles the bartender pours, LL is the level of the glass, and NN is the number of the glass on that level.

Output

For each test case print one line in the form Case #x: y, where xx is the test case number starting from 1 and yy is the amount of wine in ml in that glass. Round yy to seven decimal places and print all seven digits.

Constraints

  • 1T1501 \le T \le 150
  • 1B500001 \le B \le 50000
  • 1L4001 \le L \le 400
  • 1NL(L+1)/21 \le N \le L(L+1)/2