Overlaying Maps

In the picture below you can see two rectangles ABCD and A1B1C1D1. They are two rectangular maps of the same rectangular region. The size of the two maps is different but their aspect ratio is the same. This means AB/A1B1=AD/A1D1. Mathematicians say that there is al- ways a geographical location on the big- ger map such that the same location on the smaller map lies just straight above. So you can mark this location with one needle on both the maps at the same time. In the figure on the left, point E is such a point. Given the orientation of the two maps of the same rectangu- lar area your job is to find this special point. You can assume that the bigger map is ABCD and the smaller map is A1 B1 C1 D1 . You can also assume that point A is always at the origin, and one side of the bigger map is always in paral- lel with the x-axis. So obviously the other side is always in parallel with the y-axis. Input On the first line there will be T (1 ≤ T ≤ 500) , the number of test cases. Each case is represented by five lines. First of them will contain the coordinates of point C. The next four lines will contain coordinates of points A1, B1, C1 and D1 respectively. You can assume that (10 ≤ AB, AC ≤ 100) and 0.1 ≤ (A1B1/AB) ≤ 0.9 Output For each test case you must produce one line of output: the coordinates of the desired point rounded to four digits after the decimal point. You can always assume that there will be one such point. Sample Input 2 8.0000000000 6.0000000000 2.0000000000 1.0000000000 6.0000000000 1.0000000000 6.0000000000 4.0000000000 2.0000000000 4.0000000000 34.0000000000000000 49.0000000000000000 18.2078241256558856 32.1681558770129171 22.7579122488961215 27.1147710637666363 30.0407315385745850 33.6722510060834468 25.4906434153343492 38.7256358193297276

2/2 Saple Output 4.0000 2.0000 26.6101 32.5721