Given an orthogonal polygon room with a lamp, trace rays that reflect once off the walls and find the total wall length left unlit.
Hard8GeometrySimulationNo attempts yetTime limit8sMemory limit512 MBYou are given floor plans of polygonal rooms. Every wall runs parallel to the x axis or to the y axis. The walls are made of a special material, so they reflect light the way mirrors do, but only once. Light that has already been reflected at some point of the walls is not reflected again.
Each room holds one lamp. Light leaves the lamp in every direction and travels in straight lines. Where a ray first meets a wall, that point becomes illuminated and the ray is reflected so that the angle of reflection equals the angle of incidence. Where the reflected ray meets a wall, that point becomes illuminated and the ray stops there.
Because the walls reflect light only once, part of the walls may receive no light at all. Compute the total length of the unilluminated part of the walls.

The figure shows the second room of the sample input.
The input consists of several test cases.
The first line of each test case contains one even integer N (4≤N≤20), the number of corners. Each of the next N lines describes one corner in counterclockwise order, and the i-th of those lines contains two integers xi and yi, the coordinates of the i-th corner. The last line of the case contains x′ and y′, the coordinates of the lamp.
The input satisfies the following conditions.
The last line of the input contains a single 0.
For each test case, print the total length of the unilluminated part of the walls on one line. Round the value at the third digit after the decimal point and print exactly three digits after the decimal point.