#K7481. House Building on a Grid

    ID: 34280 Type: Default 1000ms 256MiB

House Building on a Grid

House Building on a Grid

You are given a grid of size \(m \times n\) and a list of \(t\) plots where houses are to be built. Each plot is specified by its row and column indices (1-indexed). However, there is a restriction: no two houses can be adjacent in the up, down, left, or right direction. In other words, if a house is built on a plot, its direct neighbors (above, below, left, right) cannot have a house.

Your task is to determine if it is possible to build a house on each of the given plots without violating the above condition.

Note: All indices are 1-indexed.

The adjacency condition is mathematically given as:

[ \text{For a house built at } (r, c), ; \forall; (r', c') \text{ such that } |r - r'| + |c - c'| = 1, ; \text{grid}[r', c'] = 0. ]

inputFormat

The first line contains three integers \(m\), \(n\), and \(t\) where \(m\) is the number of rows, \(n\) is the number of columns, and \(t\) is the number of plots.

Each of the following \(t\) lines contains two integers \(r\) and \(c\) denoting the row and column indices of a plot where a house must be built.

outputFormat

Output a single line containing either "Yes" if it is possible to build houses on the given plots without any adjacent houses, or "No" if it is not possible.

## sample
5 5 3
1 1
2 2
3 3
Yes