Compute the total length of a straight track segment from which the main rectangle stays fully visible behind other rectangles.
Hard8GeometryIntervalsNo attempts yetTime limit1sMemory limit256 MBAn 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.
The input holds several test cases. The first line of a test case has the number of aviaries N (1≤N≤100). The second line has the coordinates of the planned track in the format x1 y1 x2 y2, where [x1,y1] is the start of the track and [x2,y2] is the end. The track has no thickness. The next N 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 x1 y1 x2 y2 x3 y3 x4 y4, in clockwise or anticlockwise order. The main aviary comes first. All coordinates are integers with absolute value less than 10000. 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 0.
For each test case print on its own line the total length L 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.