There is a car, a bus, and a truck moving in the same direction on an infinite road. The road has two lanes labeled Lane 1 and Lane 2. The bus will keep moving forward staying on Lane 1 with a constant speed SB meters per second and the car will keep moving forward staying on Lane 2 with a constant speed SC meters per second. They will not change their lanes or speeds. The length of the bus is LB meters and it is DB meters ahead of the truck. The length of the car is LC meters and it is DC meters ahead of the truck. The length of the truck is LT meters and the maximum speed of the truck is ST meters per second.
The truck wants to overtake both of the vehicles without any accidents. The truck will overtake the car, if it is at least LT meters ahead of the car. Similarly, the truck will overtake the bus, if it is at least LT meters ahead of the bus.
If the truck is driven on lane 1, the truck must stay at least LB meters behind the bus or at least LT meters ahead of the bus to avoid an accident with the bus. Similarly, if the truck is driven on lane 2, the truck must stay at least LC meters behind the car or at least LT meters ahead of the car to avoid an accident with the car.
You may safely assume:
- No accident has occurred till now.
- The truck is either on lane 1 or lane 2, we do not know. The truck driver can instantly change between lane 1 and lane 2.
- The truck driver can instantly change its current speed to any value between 0 to ST meters per second.
- Each lane contains sufficient space for only one vehicle and at any particular moment the truck will be driven either on lane 1 or lane 2.
You are given all the information, you have to find out the minimum amount of time the truck will take to overtake both of the vehicles.
Input
First line of the input file contains a positive integer T (T ≤ 100000) which denotes the number of test cases to follow.
Each of the next T test cases contains three lines of inputs. The first line of the test case contains three space-separated integers LB (1 ≤ LB ≤100), SB (1 ≤ SB ≤100), and DB (1 ≤ DB ≤1000). The next line contains three space-separated integers LC (1 ≤ LC ≤100), SC (1 ≤ SC ≤100), and DC (1 ≤ DC ≤1000). The last line of the case contains two space-separated integers LT (1 ≤ LT ≤100) and ST (1 ≤ ST ≤100).
You may safely assume that LC≤ DC or LB ≤ DB or both are valid.
Output
For each case, print Case t: x
, where t is the test case number and x is the minimum time to overtake both of the vehicles rounded up to four digits after decimal points. If it is impossible to overtake both vehicles, then print -1
instead.
Sample
Sample Input | Sample Output |
---|---|
2 5 10 10 5 10 10 50 20 5 10 100 5 5 10 10 100 | Case 1: -1 Case 2: 1.2222 |
Notes
Large I/O, Avoid endl with cout.