Let's consider a bar rotating clockwise as if it were a twirling baton on a plane surrounded by a polygonal wall (see Figure 1).
\includegraphics{https://static.e-olymp.com/content/ba/ba0ece2a623f0c77437cdf1314601a7cf85ae1c3.jpg}
Figure 1. A bar rotating in a polygon
Initially, one end of the bar (called end A) is at , and the other end (called end B) is at , where is the length of the bar. The bar initially touches the wall only at end A.
The bar turns by fixing a touching point as the center; this center changes each time a new point touches the wall.
Your task is to compute the coordinates of end A after the bar has made full turns (or as far as possible, if it gets stuck before completing turns).
\includegraphics{https://static.e-olymp.com/content/36/36fa20fba88ac68d38475da99a35a345a353d4bb.jpg}
Figure 2. Examples of turning bars
In Figure 2, some examples are shown. In cases (D) and (E), the bar becomes stuck (that is, it cannot rotate further clockwise with any touching point as center) before completing full turns. In such cases, report the coordinates of end A in this stuck position.
You may assume the following: if the length changes by (|\varepsilon| < 0.00001), the final coordinates will not change by more than .
The input consists of multiple test cases (datasets). The number of test cases does not exceed . Input is terminated by a line containing "0 0 0".
Each test case is formatted as follows:
\includegraphics{https://static.e-olymp.com/content/49/49270e28ebc371c9e6e548fe5edf6353526f0ecb.jpg}
Here, is the length of the bar. The bar rotates radians (that is, full turns) if not stuck prematurely. is the number of vertices of the polygon.
The vertices of the polygon are given in counterclockwise order. You may assume that the polygon is simple (its border does not cross or touch itself).
, X_i, and Y_i are integer numbers; and are decimal fractions. The ranges of these values are:
For each test case, print one line containing the - and -coordinates of the final position of end A, separated by a space. Your answer must not differ from the correct value by more than . You may print any number of digits after the decimal point, but at least three decimal places of precision are required.
Note that the example input corresponds to the cases in Figure 2. For convenience, Figure 3 shows an animation and photographic sequence for case (C).
\includegraphics{https://static.e-olymp.com/content/7b/7b13b2e55ad078ef0bf7a0d5d7037554d9381312.gif}
\includegraphics{https://static.e-olymp.com/content/1e/1e244d4685cf610b1ebf501717ded1cb8a1f0ddc.jpg}
Figure 3. Animation and photographic sequence for case (C)
Example 1