eolymp
bolt
Try our new interface for solving problems

Robot

Robot to go on a plane from point \textbf{A} to point \textbf{B}. Walk a straight line is not always possible because of the obstacles. Need to write a program that computes the minimum path length of the robot from point \textbf{A} to point \textbf{B}. We assume the size of the robot is negligibly small compared to overcame distance and size of obstacles. We assume that all the obstacles represented by a set of segments on the plane. These segments of the robot can not intersect at interior points, but he can pass through the ends of the segments, and can also walk along the segment. \InputFile The first line contains one integer \textbf{N} --- number of segments, constraints (\textbf{0} <= \textbf{N} <= \textbf{100}). Then there are \textbf{N} rows of four integers \textbf{X_1}, \textbf{Y_1}, \textbf{X_2} and \textbf{Y_2} in each. It coordinates all of the segment. The last two lines contain \textbf{X} and \textbf{Y} coordinates of points \textbf{A} and \textbf{B}. It is guaranteed that all the coordinates of the module does not exceed \textbf{1000}, and none of the ends of the segments do not belong to another segment. The starting and ending points are different ways and do not belong to any segment. \OutputFile Bring one number - the length of the shortest path from point \textbf{A} to point \textbf{B} with four characters after the decimal point. If the desired path does not exist, then print out \textbf{-1}.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1
5 -2 5 3
10 0
0 0
Output example #1
10.7703
Author Pavel Kuzhnecov