Welcome to ZOJ
Information
Select Problem
Runs
Ranklist
ZOJ Problem Set - 3419
Detector Placement

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Dr. Gale is testing his laser system. He uses a detector to collect the signals from a fixed laser generator. He also puts a special prism in the system so that he can filter the noise. But he is not very sure where to put the detector to collect the signals. Can you help him with this problem?


Here n1 and n2 are the refractive indices of the two media.

In order to simplify the problem, here we assume the prism is a triangle. The laser generator will not be placed on the surface of the prism or inside the prism. The laser goes in one direction and the detector can receive signals from any direction. The detector is place on the ground where the y-coordinate is zero. There is no energy lost in the refraction. That is to say, there is no reflection in the signal transmission. You can assume that there is no total reflection or the situation that the laser passes the vertex of the prism.

Given the position and the direction of the laser generator and the prism, you are asked to find the position of detector so that it can receive the signals from the laser generator.

Input

The input contains multiple test cases. The first line is the total number of cases T (T ≤ 30). The first line of each test case contains 2 integers, indicating the coordinates of the laser generator. The second line contains 2 integers describing a point the laser will go through when the prism is not placed. The third line contains 6 integers describing the three vertices of the prism. The fourth line contains a real number u, the refractive index of the prism (1 < u ≤ 10). We assume the refractive index of the air is always 1.0. The absolute value of the coordinates will not exceed 1000. The y coordinates are all nonnegative. The prism and the laser generator are strictly above the ground and the laser generator will not be inside the prism.

Output

If there is no place in the ground that can receive the signals output "Error". Otherwise, output the x coordinate of the place accurate to 0.001.

Sample Input

2
0 10
0 0
-1 3 1 2 -1 1
1.325
0 10
0 20
-1 3 1 2 -1 1
1.325

Sample Output

-0.658
Error


Author: GUAN, Yao
Source: The 2010 ACM-ICPC Asia Chengdu Regional Contest
Submit    Status