Background
Will I be able to wait until the dream wakes?
Yue had a dream. In the dream, she obtained an integer sequence $a_1, \ldots, a_n$ of length $n$, where $n \ge 5$.
The dream ended. Yue forgot some of the elements in the sequence, leaving blanks. Fortunately, Yue still remembers $m$ non-blank positions. Yue wants to fill in the blanks to restore the entire sequence.
Yue also remembers that the sequence in her dream had the following property: for all distinct indices $x_1, x_2, x_3, x_4$ satisfying $x_2 + x_3 = x_1 + x_4$, the condition $a_{x_2} + a_{x_3} = a_{x_1} + a_{x_4}$ always holds.
Yue wants to know if it is possible to restore a sequence that satisfies this property (if not, she must have remembered it incorrectly). If it is possible, output Yes; otherwise, output No.
Input
This problem contains multiple test cases.
The first line contains an integer $T$, representing the number of test cases.
The input for each test case follows:
- The first line contains two integers $n, m$, where $n \ge 5$ and $m$ is the number of non-blank positions in $a_i$.
- The next $m$ lines each contain two integers $p_i, x_i$, indicating that $a_{p_i}$ is not blank and $a_{p_i} = x_i$. It is guaranteed that all $p_i$ are distinct.
Output
For each test case, output a string Yes or No, indicating whether the original sequence exists.
In this problem, the string is case-insensitive; that is, yes, yeS, yEs, Yes, YEs, YeS, yES, YES are all considered Yes, and similarly for No.
Examples
Input 1
3 5 3 1 1 4 4 5 5 6 6 1 1 3 7 2 4 5 5 4 1 6 4 5 0
Output 1
Yes No Yes
Note 1
For the first test case, the current sequence is $[1, ?, ?, 4, 5]$. We can construct the original sequence $[1, 2, 3, 4, 5]$, and you can verify that this sequence satisfies the property.
For the second test case, the current sequence is $[1, 4, 7, 1, 5, 4]$. It can be proven that no original sequence satisfying the property exists. This example reminds you that $p$ is not necessarily given in ascending order.
For the third test case, the current sequence is $[?, ?, ?, ?, ?]$. We can construct the original sequence $[0, 0, 0, 0, 0]$; of course, $[-1, -1, -1, -1, -1]$ would also work. This example reminds you that $m$ can be $0$, and the original sequence can contain negative numbers or $0$.
Input 2
1 5 2 1 -2 5 -10
Output 2
Yes
Input 3
2 9 6 1 -856675560 8 479857596 5 -92942328 4 -283875636 3 -474808944 9 670790904 10 7 4 -32297373 10 -633066970 9 831032854 5 -43726758 2 -699796467 1 -918486370 8 612342951
Output 3
Yes No
Constraints
Let $\sum n$ denote the sum of $n$ over a single test case.
For all test cases, $1 \le T \le 4 \times 10^4$, $5 \le n \le 2 \times 10^5$, $\sum n \le 2 \times 10^5$, $0 \le m \le n$, $1 \le p_i \le n$, $-10^9 \le x_i \le 10^9$. It is guaranteed that all $p_i$ are distinct within the same test case.
This problem uses bundled testing.
- Subtask 1 (20 points): $n \le 2000$ and $m = n$.
- Subtask 2 (30 points): $n \le 6$, $|x| \le 7$.
- Subtask 3 (20 points): $m = 2$.
- Subtask 4 (30 points): No special restrictions.