Visitors' Train
Time limit1sMemory limit256 MB
Compute the total length of a straight track segment from which the main rectangle stays fully visible behind other rectangles.
Problem
An aviary is a large cage for birds. A big zoo aviary is typically tens of meters across, and the birds inside fly around and live in conditions close to the wild. In theory, at least. The zoo has one main aviary that is large and worth looking at, plus several less important ones.
The zoo plans to build a short straight electric train track so that visitors move easily from one part of the zoo to another. Someone has to decide which of the free areas the track runs through. On his trips to other zoos the director noticed that visitors are happier when they can take more photos of important zoo structures, and he wants to measure the quality of the planned track by that. The most important structure near the track is the main aviary. The director worries that the less important aviaries along the track hide the main aviary and leave visitors less happy. Help the director rate the planned track.

You are given the coordinates of every aviary and the coordinates of the start and the end of the planned track. Find the total length of the parts of the track from which the main aviary is visible and is not hidden, not even partly, by any other aviary. Visitors look out of the train in any direction.
Input
The input holds several test cases. The first line of a test case has the number of aviaries (). The second line has the coordinates of the planned track in the format , where is the start of the track and is the end. The track has no thickness. The next lines describe one aviary each. An aviary is a rectangle with nonzero area, and its line has the coordinates of the four corners in the format , in clockwise or anticlockwise order. The main aviary comes first. All coordinates are integers with absolute value less than . No aviary crosses or touches the track, and no aviary crosses or touches another aviary. There is no blank line between consecutive test cases. The input ends with a line holding a single .
Output
For each test case print on its own line the total length of the parts of the planned track from which the main aviary is visible and is not hidden, not even partly, by any other aviary. Round at the seventh decimal place and always print six digits after the decimal point. Print 0.000000 when no such part exists.
The main aviary does not count as hidden when only its corners or edges are covered, that is, when the hidden range of viewing angles has width zero.