Vote (Small)

Given N supporters of A and M of B, find the probability that A leads after every vote in a random arrival order.

Easy3MathProbabilityCombinatoricsNo attempts yetTime limit5sMemory limit512 MB

Problem

A and B are the only two candidates in an election. Polls show that exactly NN voters support A and exactly MM voters support B. Since NN is greater than MM, A wins the election.

Voters arrive at the polling place one at a time. The arrival order is chosen uniformly at random among all (N+M)!(N + M)! possible orders. After each vote, the polling place worker updates the running count and writes down which candidate is ahead at that moment. If the two counts are equal, no candidate is ahead.

Compute the probability that A is ahead after every single vote, from the first one to the last.

Input

The first line contains the number of test cases TT. Each test case is one line with two integers NN and MM, the number of voters supporting A and the number supporting B.

Limits

  • 1T1001 \le T \le 100
  • 0M<N100 \le M < N \le 10

Output

For each test case, print one line in the form Case #x: y. Here x is the test case number, starting from 1, and y is the probability that A is ahead after every vote.

Print y rounded to exactly eight digits after the decimal point, padding with zeros when needed. For example, a probability of 1 is printed as 1.00000000.

Notes

Take N=2N = 2 and M=1M = 1. Call the supporters of A A1 and A2, and the supporter of B just B. The six possible arrival orders are A1 A2 B, A2 A1 B, A1 B A2, A2 B A1, B A1 A2, B A2 A1. Only the first two keep A ahead after every vote. With the order A1 B A2, A is ahead after the first vote but the count is tied after the second one. The answer is 2/6=0.333333332/6 = 0.33333333\ldots

With N=1N = 1 and M=0M = 0 there is a single voter, and that voter supports A. Only one order exists, and A is ahead after that one vote.