Consider a fictitious solar system made up of a star S, a planet P, and its moon M. Planet P travels around star S on a perfect circular orbit with a revolution period of exactly T Earth days. Moon M travels around planet P on a perfect circular orbit whose revolution period is unknown.
Given the position of moon M relative to star S at three different times, your goal is to compute the distance from star S to planet P.
Work in a two-dimensional Cartesian coordinate system whose origin is star S. Assume that P's counterclockwise orbit around S and M's counterclockwise orbit around P both lie entirely in the xy-plane. Let (x1,y1) be the position of moon M at the first observation, (x2,y2) its position k1 Earth days later, and (x3,y3) its position k2 Earth days after the second observation.
The input contains several test cases. Each test case consists of two lines. The first line contains the integers T, k1, and k2 with 1≤T,k1,k2≤1000. The second line contains six floating-point values x1, y1, x2, y2, x3, and y3. The input points are chosen so that the solution is unique, and the final distance from planet P to star S is always within 0.1 of the nearest integer. The end of input is marked by a single line containing 0 0 0.
For each test case, print the distance from planet P to star S, rounded to the nearest integer, on its own line.