Eli is playing a game where she can draw a number of lines in the plane and then, starting at a point on one of her lines, she can move along the lines that she drew in any direction.
Eli has just created a level in this game by drawing straight line segments and picking two points on her drawing. She then has to move from one of the points to the other by following the lines. Eli would like your help to figure out the shortest distance that she must travel to get from one point to the other.
Input Specification
The first line of input contains an integer , the number of line segments that Eli has drawn. The next lines each contain four integers , representing a line segment from point to a point . The last line contains four integers , the two points.
Output Specification
The minimum distance that a player must travel along the lines to get from one point to the other. Your answer will be considered correct if it has an absolute or relative error of at most .
If it is impossible to travel from one point to the other, output -1
.
Sample Input 1
2
0 0 0 1
1 0 1 1
0 0 1 1
Sample Output 1
-1
Sample Input 2
2
0 0 2 0
1 -1 1 2
1 1 0 0
Sample Output 2
2.00
Comments