#C1849. Communication with Magical Lamp Post

    ID: 45099 Type: Default 1000ms 256MiB

Communication with Magical Lamp Post

Communication with Magical Lamp Post

In a city laid out in a grid, there are (n) horizontal and (m) vertical streets. A magical lamp post is located at position ((r_x, c_x)). This lamp post can communicate directly with any other lamp post that lies in the same row or the same column.

You are given (q) lamp posts with their respective coordinates. For each lamp post, determine whether it can communicate directly with the magical lamp post. If it can, output YES; otherwise, output NO.

Note: Input is provided via standard input and output via standard output.

inputFormat

The first line of input contains five space-separated integers (n), (m), (q), (r_x), and (c_x), which represent the number of horizontal streets, the number of vertical streets, the number of lamp posts to check, and the coordinates of the magical lamp post, respectively. This is followed by (q) lines, each containing two space-separated integers (r_i) and (c_i) representing the coordinates of a lamp post.

outputFormat

For each of the (q) lamp posts, output a single line containing YES if the lamp post is in the same row or column as the magical lamp post, or NO otherwise.## sample

5 5 3 3 3
1 3
3 4
5 5
YES

YES NO

</p>