403194: GYM101064 A Renzo and the lost artifact
Description
After unfolding the mysteries of the palindromic decorations in the Thai ruins, the famous researcher Renzo "the fearless" Morales is searching for a Sioux artifact. Some people believe that such artifact got lost a long time ago during the struggles between the Sioux and the north-american settlers.
Renzo believes that this artifact was hidden from the north-americans, and after a long search, he found clues to its location. The clues are two old maps of the region that today is known as Rapid City. Both maps have rectangular shape and show exactly the same region, but one is on a larger scale than the other. Renzo noticed that the corners of the smaller map are numbered from 1 to 4, and in the interior of the larger map exist four points numbered from 1 to 4 forming a rectangle of the exact same size of the smaller map.
Being a proficient problem solver, the famous researcher came rapidly to the conclusion that the smaller map has to be put on top of the larger map, in such a way that the numbered points coincide. Considering that both maps are in the Cartesian plane with the origin at the lower left corner of the larger map, the place where the artifact is hidden must correspond to a point in the plane that represents the same location in both maps.
To help Renzo find this precious historic artifact, write a program that finds one of these points.
InputThe first line contains two integers H and W (10 ≤ H, W ≤ 1000), that represent the height and the width of the map, respectively. The following lines contain four pairs of values xi, yi (0 < xi < W, 0 < yi < H), one pair per line, indicating the coordinates of the smaller map, starting from its lower left corner (regarding the original orientation), followed by its lower right corner, upper right and finally the upper left corner. The coordinates are given with exactly 8 decimal places. Its guaranteed that the ratio between the scales of the smaller and larger map is between 0.01 and 0.99, inclusive.
OutputPrint a single line containing two numbers xp, yp: the coordinates of the point corresponding to the location of the artifact in both maps. Absolute or relative errors up to 10 - 4 will be tolerated. If there are multiple solutions, print any of them. It is guaranteed that at least one exists.
ExamplesInput10 20Output
8.00000000 4.00000000
12.00000000 4.00000000
12.00000000 6.00000000
8.00000000 6.00000000
10.000000 5.000000Input
10 10Output
5.00000000 4.50000000
2.50000000 4.50000000
2.50000000 7.00000000
5.00000000 7.00000000
4.000000 6.000000