Problem A: Railway |
Railway is a broken line of N segments. The problem is to find such a position for the railway station that the distance from it to the given point M is the minimal.
The input will consist of several input blocks. Each input block begins with two lines with coordinates Xm and Ym of the point M. In the third line there is N - the number of broken line segments. The next 2N+2 lines contain the X and the Y coordinates of consecutive broken line corners.
The input is terminated by <EOF>.
For each input block there should be two output lines. The first one contains the first coordinate of the station position, the second one contains the second coordinate. Coordinates are the floating-point values with four digits after decimal point.
6 -3 3 0 1 5 5 9 -5 15 3 0 0 1 1 0 2 0
7.8966
-2.2414
1.0000
0.0000
Olga Zaverach, 2002