Pinely Round 3 (Div. 1 + Div. 2)
A
Distinct Buttons
Codeforces
800
原题
←B →
翻译中…
翻译中…

You are located at the point $(0, 0)$ of an infinite Cartesian plane. You have a controller with $4$ buttons which can perform one of the following operations:

翻译中…
  • $\texttt{U}$: move from $(x, y)$ to $(x, y+1)$;
  • $\texttt{R}$: move from $(x, y)$ to $(x+1, y)$;
  • $\texttt{D}$: move from $(x, y)$ to $(x, y-1)$;
  • $\texttt{L}$: move from $(x, y)$ to $(x-1, y)$.
翻译中…

Unfortunately, the controller is broken. If you press all the $4$ buttons (in any order), the controller stops working. It means that, during the whole trip, you can only press at most $3$ distinct buttons (any number of times, in any order).

翻译中…

There are $n$ special points in the plane, with integer coordinates $(x_i, y_i)$.

翻译中…

Can you visit all the special points (in any order) without breaking the controller?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the number of special points.

翻译中…

Each of the next $n$ lines contains two integers $x_i$, $y_i$ ($-100 \leq x_i, y_i \leq 100$), which represent the special point $(x_i, y_i)$.

翻译中…

Note that there are no constraints on the sum of $n$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output "YES" (without quotes), if you can reach all the special points without breaking the controller, and "NO" (without quotes) otherwise.

翻译中…

You may output each letter in any case (for example, "YES", "Yes", "yes", "yEs" will all be recognized as positive answer).

翻译中…

Note

翻译中…

In the first test case, you can move as follows:

翻译中…
  • you start from $(0, 0)$;
  • you visit the special point $(x_2, y_2) = (0, 0)$;
  • you press $\texttt{R}$, and you move from $(0, 0)$ to $(1, 0)$;
  • you press $\texttt{D}$, and you move from $(1, 0)$ to $(1, -1)$;
  • you visit the special point $(x_1, y_1) = (1, -1)$;
  • you visit the special point $(x_3, y_3) = (1, -1)$.
翻译中…

Therefore, you can visit all the special points using only the buttons $\texttt{R}$, $\texttt{D}$, so the controller does not break.

翻译中…

Note that the special points may coincide.

翻译中…

In the second test case, you can show that you can visit all the special points using only the buttons $\texttt{U}$, $\texttt{D}$, $\texttt{L}$.

翻译中…

In the third test case, you can show that you must press all the buttons ($\texttt{U}$, $\texttt{R}$, $\texttt{D}$, $\texttt{L}$) to visit all the points, so the controller would break.

翻译中…

样例

Input #1
6
3
1 -1
0 0
1 -1
4
-3 -2
-3 -1
-3 0
-3 1
4
1 1
-1 -1
1 -1
-1 1
6
-4 14
-9 -13
-14 5
14 15
-8 -4
19 9
6
82 64
39 91
3 46
87 83
74 21
7 25
1
100 -100
Output #1
YES
YES
NO
NO
YES
YES
InputCopy OutputCopy
题目信息
题号
1909A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

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