Олимпиадный тренинг

Задача 38445. Mirrors


Once the evil wizard Sarumyan looked into the video chat and saw a system of N mirrors there. He thought for a long time before an inner voice told him that the system was not simple. He realized that if you look at this system from a certain angle, and see a given point A through all N mirrors (that is, so that his gaze is reflected through each of them exactly once, and then hit point A), then they will open all the secrets of the Internet to him. 
However, the forces of light did not doze off and, through the agent network, found out everything about this video chat. 
It is required to write a program that would tell the forces of light from what angle they need to look at the system of mirrors in order to find out all the secrets of the Internet.

Input:
The first line of the input file contains a single number – number of mirrors (0<N≤10). The next line contains the coordinates (x and y, where the x-axis is directed to the right, the y-axis – up) of the starting point (where you need to look at the mirrors) and point A. Next, N lines contain information about the mirrors – four numbers each, indicating the coordinates of the beginning and end of the mirror. The reflective surface is located on the left side of the mirror (when viewed from the first point towards the second). Mirrors are transparent on the reverse side.
Moreover, the following restrictions are met:
     All coordinates are real and do not exceed 10000 in absolute value
     No mirrors intersect 
     End and start points do not lie on any of the mirrors

Output:
The first line of the output file must be written YES if the solution exists, and NO if not. If there is a solution, then in the second line you need to write down the angle in degrees (with an accuracy of six decimal places), under which you need to look at the mirrors. The angle is counted counterclockwise from the Ox axis and ranges from 0 to 360 degrees.
Examples
# Input Output
1
0 0
05
1 0 1 2
-1 4 –1 2
YES
51.340192