The input consists of a number of datasets. The end of the input is indicated by a line containing a zero.
Each dataset is formatted as follows.
Each value in the dataset except n is an integer no less than 0 and no more than 100.
n
PX1 PY1 QX1 QY1
...
PXn PYn QXn QYn
TX TY
LX LY
The first line of a dataset contains an integer n (1 ≤ n ≤ 5), representing the number of mirrors.
The following n lines list the arrangement of mirrors on the plane.
The coordinates (PXi, PYi) and (QXi, QYi) represent the positions of both ends of the mirror. Mirrors are apart from each other. The last two lines represent the target position (TX, TY) and the position of the beam generator (LX, LY). The positions of the target and the generator are apart from each other, and these positions are also apart from mirrors.
The sizes of the target object and the beam generator are small enough to be ignored. You can also ignore the thicknesses of mirrors.
In addition, you can assume the following conditions on the given datasets.
There is at least one possible path from the beam generator to the target. The number of reflections along the shortest path is less than 6. The shortest path does not cross or touch a plane containing a mirror surface at any points within 0.001 unit distance from either end of the mirror. Even if the beam could arbitrarily select reflection or passage when it reaches each plane containing a mirror surface at a point within 0.001 unit distance from one of the mirror ends, any paths from the generator to the target would not be shorter than the shortest path.
When the beam is shot from the generator in an arbitrary direction and it reflects on a mirror or passes the mirror within 0.001 unit distance from the mirror, the angle θ formed by the beam and the mirror satisfies sin(θ) > 0.1, until the beam reaches the 6th reflection point (exclusive).
Figure G-1 corresponds to the first dataset of the Sample Input below.
Figure G-2 shows the shortest paths for the subsequent datasets of the Sample Input.
Figure G-2: Examples of the shortest paths