Risk

Compute the attacker win probability in a Risk battle with D-sided dice where the defender picks one or two dice after seeing the attack roll.

Medium7Dynamic programmingProbabilityGame theoryCombinatoricsNo attempts yetTime limit2sMemory limit256 MB

Problem

Vladimir and Mark play the strategy board game Risk. Players occupy regions of the world and try to conquer whole continents. Mark holds a region with MM armies and wants to attack an adjacent region that Vladimir holds with NN armies. Mark is the weaker player, so he asks you for the probability that he wins that battle.

The battle follows the standard Risk rules, with one change: the dice do not have to be six sided. Every die has DD sides with D1D \ge 1, the sides carry different values, and each side comes up with the same probability.

A battle is a sequence of rounds. Suppose the attacker has AA armies in the region he attacks from and the defender has BB armies in his region. One round runs like this.

  1. The attacker rolls min(3,A1)\min(3, A - 1) dice. He uses three dice when he can, but one army has to stay in the region and takes no part in the attack, so for A<4A < 4 he rolls A1A - 1 dice.
  2. The defender looks at the attacker's dice and then rolls. If B=1B = 1 he rolls one die. If B2B \ge 2 he rolls one or two dice, and he picks the count that makes his own probability of winning the whole battle as large as possible.
  3. Let cc be the smaller of the two dice counts. The highest die of each player is compared, and when c=2c = 2 the second highest die of each player is compared as well. In every comparison the larger value wins, and the defender wins a tie. The loser of a comparison removes one army from his region. Any extra dice are ignored.

The battle ends when the attacker has only one army left, and then the defender has won, or when the defender has no army left, and then the attacker has won.

For example, the attacker rolls three dice showing 4, 2 and 1 while the defender rolls two dice showing 3 and 2. The first comparison is 4 against 3, which the attacker wins. The second comparison is 2 against 2, which the defender wins. Both players lose one army. For another example, if the two highest dice of the attacker both show the largest value DD, the defender is better off rolling a single die, because then he loses at most one army.

Vladimir knows the rules and the dice, and he defends so that Mark's probability of winning the battle is as small as possible.

Input

The first line contains an integer TT, the number of test cases. Each test case is given on two lines.

  • One line with an integer DD (1D201 \le D \le 20), the number of sides of the dice.
  • One line with two space separated integers MM and NN (2M1002 \le M \le 100, 1N1001 \le N \le 100), the number of armies in Mark's region and the number of armies in Vladimir's region.

Output

For each test case print one line with the probability that Mark wins the battle, rounded to exactly six digits after the decimal point. Do not use scientific notation.