Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3219
Interesting Game

Time Limit: 1 Second      Memory Limit: 32768 KB

JAVAMAN and CPCS are playing an interesting game now. The game is simple: At first JAVAMAN has A apples and CPCS has B. At each round of the game they toss a coin.If the result is "Head" then JAVAMAN should give C apples to CPCS otherwise CPCS should give D apples to JAVAMAN. The coin is biased. The propbility of tossing it to result "Head" is p. The one who cannot give the predefined numbers of apples to the other is the loser.

Here comes the problem. What is propbility that JAVAMAN can win?

Input

This problem has several test cases. The first line of the input is an integer T (1<=T<=50) indicates the number of test cases. The next T lines each contains 4 integers and a float number: A,B,C,D and p(0<=A,B<50 0<C,D<=100 0<=p<=1).

Output

For each test case output the propbility JAVAMAN can win, exact to two digits to the right of the decimal point.

Sample Input

2
1 1 1 1 0
0 0 1 1 1

Sample Output

1.00
0.00

Author: CAO, Peng
Source: ZOJ Monthly, June 2009
Submit    Status