Codeforces Round 885 (Div. 2)
A
Vika and Her Friends
Codeforces
900
原题
←B →
翻译中…

Vika and her friends went shopping in a mall, which can be represented as a rectangular grid of rooms with sides of length $n$ and $m$. Each room has coordinates $(a, b)$, where $1 \le a \le n, 1 \le b \le m$. Thus we call a hall with coordinates $(c, d)$ a neighbouring for it if $|a - c| + |b - d| = 1$.

翻译中…

Tired of empty fashion talks, Vika decided to sneak away unnoticed. But since she hasn't had a chance to visit one of the shops yet, she doesn't want to leave the mall. After a while, her friends noticed Vika's disappearance and started looking for her.

翻译中…

Currently, Vika is in a room with coordinates $(x, y)$, and her $k$ friends are in rooms with coordinates $(x_1, y_1)$, $(x_2, y_2)$, ... $, (x_k, y_k)$, respectively. The coordinates can coincide. Note that all the girls must move to the neighbouring rooms.

翻译中…

Every minute, first Vika moves to one of the adjacent to the side rooms of her choice, and then each friend (seeing Vika's choice) also chooses one of the adjacent rooms to move to.

翻译中…

If at the end of the minute (that is, after all the girls have moved on to the neighbouring rooms) at least one friend is in the same room as Vika, she is caught and all the other friends are called.

翻译中…

Tell us, can Vika run away from her annoying friends forever, or will she have to continue listening to empty fashion talks after some time?

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of test cases. The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $m$, $k$ ($1 \le n, m, k \le 100$) — the sizes of the mall and the number of Vika's friends.

翻译中…

The second line of each test case contains a pair of integers $x$ and $y$ ($1 \le x \le n$, $1 \le y \le m$) — the coordinates of the room where Vika is.

翻译中…

Each of the next $k$ lines of each test case contains a pair of integers $x_i$ and $y_i$ ($1 \le x_i \le n$, $1 \le y_i \le m$) — the coordinates of the room where the $i$-th friend is.

翻译中…

Output

翻译中…

For each test case, output "YES" if Vika can run away from her friends forever, otherwise output "NO".

翻译中…

You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

翻译中…

Note

翻译中…

In the first test case, the friend will never catch up with Vika, because Vika can always move to the room diagonally opposite to the one where the friend is.

翻译中…

In the second test case, no matter where Vika goes, each of her friends can catch her after the first move.

翻译中…

In the third test case, Vika and her friend will always be in different halls.

翻译中…

样例

Input #1
6
2 2 1
1 1
1 2
2 2 2
1 1
2 2
2 2
1 2 1
1 1
1 2
5 5 4
3 3
1 1
1 5
5 1
5 5
2 2 2
1 1
2 1
1 2
3 4 1
1 2
3 3
Output #1
YES
NO
YES
NO
YES
YES
InputCopy OutputCopy
题目信息
题号
1848A
时间限制
1 s
内存限制
256 MB
标签
博弈论
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。