#K52087. Streetlight Placement Decision

    ID: 29231 Type: Default 1000ms 256MiB

Streetlight Placement Decision

Streetlight Placement Decision

You are given a grid representing a city layout with m horizontal roads and n vertical roads. In this city, intersections are denoted by pairs of integers (r, c) where 1 \(\leq r \leq m\) and 1 \(\leq c \leq n\). You are also given an integer k representing the number of intersections to check.

A streetlight should be placed at an intersection if either the intersection lies on the boundary of the grid (i.e., when \(r=1\), \(r=m\), \(c=1\), or \(c=n\)) or the sum of the intersection's row and column indices is even. That is, the condition for placing a streetlight can be written in \(\LaTeX\) as:

\[ (r = 1 \text{ or } r = m \text{ or } c = 1 \text{ or } c = n) \quad \text{or} \quad (r+c) \mod 2 = 0 \]

Your task is to process each intersection and output "YES" if a streetlight should be placed, otherwise output "NO".

inputFormat

The first line contains three integers m, n, and k -- the number of horizontal roads, vertical roads, and intersections to be checked, respectively.

Each of the following k lines contains two integers r and c, representing an intersection.

Input is read from standard input (stdin).

outputFormat

Output exactly k lines. For each intersection, print "YES" if a streetlight should be placed, or "NO" otherwise. The results should be printed to standard output (stdout).

## sample
4 5 3
1 3
3 4
2 2
YES

NO YES

</p>