Billiards
Time limit8sMemory limit1024 MB
Given a billiard table with balls and a coin, find every ball that, struck at 45 degrees, reaches the coin after cushion bounces before hitting another ball or a corner hole.
Problem
You are challenging a prize game that resembles billiards. The game uses a billiard table, several balls of the same size, and a prize coin. The top of the table has a flat rectangular cloth-covered area bounded by elastic bumpers called cushions. The balls move on this area. The cushions keep the centers of the balls inside a rectangular region of width and length , called the movable area.
Let the coordinates of the four corners of the movable area be , , , and . At the start of a game, all the balls and the coin are placed so that their centers are at distinct inner lattice points of the movable area, that is, points not on its boundary. The balls and the coin are small, so they do not touch each other unless a ball moves toward the center of another ball or the coin.
You choose one ball and strike it with a cue in the direction 45 degrees to the edges of the movable area. The direction is one where both the and coordinates increase. The struck ball moves straight until it reaches a boundary of the movable area, hits another ball, or drops into one of the holes at the four corners. When the ball reaches a boundary, it bounces off the cushion with a reflection angle equal to its incident angle and continues straight. When it hits another ball or drops into a corner hole, the game is over. If it hits the coin before hitting another ball or dropping into a hole, you win the coin.
Which ball should you strike to win the coin? You want to know all the balls that bring you the coin.

Figure F-1: The first and second datasets of the sample input.
For the first dataset, when ball No. 2 is struck, it goes directly toward the coin. Ball No. 4 hits the coin after bouncing off the right-side cushion. Ball No. 1 hits ball No. 2, and ball No. 3 drops into the upper right hole, so striking either of them does not win the coin.
For the second dataset, when only ball No. 1 is struck, it bounces off the cushions 5 times and passes through its original position. After bouncing twice more, it reaches the coin.
Input
The input consists of multiple datasets, each in the following format.
The first line has five integers. and are the width and length of the movable area, with and . and are the coordinates of the coin, with and . is the number of balls, with .
The balls are numbered from 1 to . Line of the following lines gives the center of ball as two integers and , with and . The positions of the coin and all the balls are mutually different.
The end of the input is a line with five zeros. The number of datasets does not exceed 50. The sum of over all datasets does not exceed .
Output
For each dataset, output on one line all the ball numbers you should strike to win the coin, separated by a single space, in ascending order. If no such ball exists, output "No" on one line.