Problem E
Shooter
Input: Standard Input

Output: Standard Output

Time Limit: 5 Seconds

 

The shooter is in a great problem. He is trapped in a 2D maze with a laser gun and can use it once. The gun is very powerful and the laser ray, it emanates can traverse infinite distance in its direction. In the maze the targets are some walls (Here this is line segments). If the laser ray touches any wall or intersects it, that wall will be destroyed and the ray will advance ahead. The shooter wants to know the maximum number of walls, he can destroy with a single shot. The shooter will never stand on a wall.

 

Input

The input file contains 100 sets which needs to be processed. The description of each set is given below:

 

Each set starts with a postive integer, N(1<=N<=500) the number of walls. In next few lines there will be 4*N integers indicating two endpoints of a wall in cartesian co-ordinate system. Next line will contain (x, y) the coordinates of the shooter. All coordinates will be in the range [-10000,10000].

 

Input is terminated by a case where N=0. This case should not be processed.

 

Output

For each set of input print the maximum number of walls, he can destroy by a single shot with his gun in a single line.

 

Sample Input                               Output for Sample Input

3
0 0 10 0
0 1 10 1
0 2 10 2
0 -1
3
0 0 10 0
0 1 10 1
0 3 10 3
0 2
0

3

2

 

 


Problemsetter: Md. Kamruzzaman, Member of Elite Problemsetters' Panel