498. Coins
Time limit per test: 0.75
second(s)
Memory limit: 262144
kilobytes
input: standard
output: standard
Andrew has just made a breakthrough in gambling: he has invented
a way to make coins which have
probability
p of landing headsup and 1 
p of landing tailsup when tossed, where
p is
some number between 0 and 1. He can't, however, control
the number
p itself, and creates coins with any
p from 0
to 1 with equal probability. That is, the value of
p is a
random value uniformly distributed on
.
Andrew has generated two coins independently.
One with probability
p and another
with probability
q of landing headsup. Random values
p and
q are both uniformly distributed on
and
are independent. Of course, neither Andrew nor we know
the numbers
p and
q, we can only try to guess them
using our observations. The observations are the following:
the first coin was tossed
n_{1} times, and
m_{1} of them landed headsup.
The second coin was tossed
n_{2} times, and
m_{2} of them landed headsup.
Your task is to compute the probability that
p <
q.
Input
The first line of the input file contains one integer
T (
) —
the number of test cases to solve. Each of the following
T lines contains 4 integers each:
n_{1},
m_{1},
n_{2},
m_{2}.
1 ≤
n_{1},
n_{2} ≤ 1000, 0 ≤
m_{1},
m_{2} ≤ 50, 0 ≤
m_{1} ≤
n_{1}, 0 ≤
m_{2} ≤
n_{2}.
Output
For each test case output one line with a floatingpoint number, the probability of
p <
q.
Your answer will be considered correct if it is within 10
^{4} of the right
answer.
Example(s)
sample input

sample output

4
2 1 4 3
8 4 16 8
2 0 6 1
2 0 2 1

0.7142857142
0.5000000000
0.5333333333
0.8000000000
