Falling Diamonds (Small)

N diamonds fall onto a pile and slide left or right at random, and you compute the probability that one stops exactly at the given spot.

Medium6ProbabilitySimulationDynamic programmingNo attempts yetTime limit5sMemory limit512 MB

Problem

Diamonds are falling from the sky. People are buying up the spots where a diamond might land, just to own a diamond if one lands there. You have been offered such a spot, and you want to know whether the offer is good.

Diamonds are shaped like diamonds: the diamond with center (X,Y)(X, Y) is the square with vertices (X1,Y)(X-1, Y), (X,Y+1)(X, Y+1), (X+1,Y)(X+1, Y) and (X,Y1)(X, Y-1). Every diamond lies in the XYXY plane. XX is the horizontal direction and YY is the vertical direction. The ground is at Y=0Y = 0, and positive YY coordinates are above the ground.

The diamonds fall one at a time along the YY axis. Each one starts at (0,Y)(0, Y) for a very large YY and falls straight down until it hits the ground or another diamond.

A diamond that hits the ground sinks until its center reaches Y=0Y = 0, then stops. So a diamond whose center is at height 00 never falls or slides any further.

A diamond that hits another diamond vertex to vertex can start sliding down without turning, in one of two directions: down and left, or down and right. If no diamond immediately blocks either side, it slides left or right with equal probability. If a diamond blocks one side, the falling diamond slides to the other side, and it keeps sliding until another diamond blocks it or it becomes buried in the ground. If diamonds block both the left and the right path, the diamond stops where it is.

Look at the example in the picture. The first diamond hits the ground and stops half buried, with its center at (0,0)(0, 0). The second diamond picks left or right with equal probability. Here it went left and stopped buried in the ground next to the first diamond, at (2,0)(-2, 0). The third diamond also hits the first one. Sliding right buries it in the ground, and sliding left leaves it above and between the two diamonds already placed. Here it went left again and stopped at (1,1)(-1, 1). The fourth diamond has nothing to choose. It slides right and ends up buried in the ground at (2,0)(2, 0).

Input

The first line contains the number of test cases TT. Each of the next TT lines contains three integers NN, XX and YY: the number of falling diamonds, and the position of the spot you are interested in. The spot you are interested in buying does not have to be at or near the ground.

Limits

  • 1T1001 \le T \le 100
  • 10000X10000-10000 \le X \le 10000
  • 0Y100000 \le Y \le 10000
  • X+YX + Y is even
  • 1N201 \le N \le 20

Output

For each test case print one line in the form Case #x: p, where x is the test case number starting from 11 and p is the probability that one of the NN diamonds stops with its center exactly at (X,Y)(X, Y). Print p rounded to six digits after the decimal point.