Mirrors
Once upon a time, the evil wizard Sarumyan gazed into a video chat and discovered a system of N mirrors. After pondering for a while, an inner voice hinted that this system was complex. He realized that if he could view a specific point A through all N mirrors from a certain angle—such that his line of sight reflected off each mirror exactly once before reaching point A—all the secrets of the internet would be unveiled to him.
However, the forces of good were not idle. Through their network of agents, they uncovered everything about this video chat.
Your task is to write a program to help the forces of good determine the angle at which to view the mirror system to uncover all the secrets of the internet.
Input
The first line of the input contains a single number, the number of mirrors (0 < N ≤ 10). The next line provides the coordinates (x and y, where the x axis points to the right and the y axis points upwards) of the observation point and point A. Following this, N lines describe the mirrors, each with four numbers representing the coordinates of the start and end points of a mirror. The reflective surface is on the left side of the mirror when viewed from the first point towards the second. The back side of the mirror is transparent.
The following constraints apply:
All coordinates are real numbers and do not exceed 10000 in absolute value.
No mirrors intersect.
The observation point and point A do not lie on any of the mirrors.
Output
The first line of the output should contain YES if a solution exists, and NO if it does not. If a solution exists, the second line should specify the angle in degrees (with a precision of six decimal places) at which to view the mirrors. The angle is measured counterclockwise from the Ox axis and ranges from 0 to 360 degrees.