Welcome to ZOJ
Select Problem
ZOJ Problem Set - 3608
Signal Detection

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Type Prism
Faces 6 parallelograms
Edges 12
Vertices 8

Dr. Gale is testing his laser system. He uses a detector to collect the signals from a 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?

In order to simplify the problem, here we assume the prism is a parallelepiped, which is a three-dimensional figure formed by six parallelograms. The laser goes in one direction and the detector can receive signals from any direction. The detector is placed on the ground where the z-coordinate is zero. There is no energy lost in the refraction. That is to say, there is no reflection in the signal transmission. You don't need to consider the situation of total reflection or the degenerate situation.


There are multiple test cases. The first line of input contains an integer T (T ≤ 50) indicating the number of test cases. Then T test cases follow.

The first line of each test case contains 3 integers, indicating the coordinates of the laser generator. The second line contains 3 integers describing a point the laser will go through without the prism. The third line contains 3 integers describing a vertex A of the prism. The fourth to the sixth lines contain 3 integers each, describing an adjacent vertex of A. The seventh line contains a real number u, the refractive index of the prism.(1 < u ≤ 10) The absolute value of the coordinates will not exceed 1000. The z 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.


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

Sample Input

0 0 10
0 0 0
-5 -5 1
5 -5 11
-5 5 1
-6 -5 2
0 0 10
0 0 11
-5 -5 1
5 -5 1
-5 5 1
-5 -5 2

Sample Output

0.423 0.000


Author: GUAN, Yao
Contest: The 9th Zhejiang Provincial Collegiate Programming Contest
Submit    Status