#P13959. [ICPC 2023 Nanjing R] 计数器

[ICPC 2023 Nanjing R] 计数器

Description

There is a counter with two buttons. Pressing the + button will increase the value on the counter by 11 and pressing the c button will set the value on the counter to 00. The initial value on the counter is 00.

Someone has performed nn operations on the counter. Each operation is to press one of the two buttons. There are mm known conditions where the ii-th condition can be described as two integers aia_i and bib_i, indicating that after the aia_i-th operation the value on the counter is bib_i.

Is there a way to press the buttons so that all known conditions are satisfied?

Input Format

There are multiple test cases. The first line of the input contains an integer TT indicating the number of test cases. For each test case:

The first line contains two integers nn and mm (1n1091 \le n \le 10^9, 1m1051 \le m \le 10^5) indicating the number of operations and the number of known conditions.

For the following mm lines, the ii-th line contains two integers aia_i and bib_i (1ain1 \le a_i \le n, 0bi1090 \le b_i \le 10^9) indicating that after the aia_i-th operation the value on the counter is bib_i.

It's guaranteed that the sum of mm of all test cases will not exceed 5×1055 \times 10^5.

Output Format

For each test case output one line. If there exists a way to press the buttons so that all known conditions are satisfied, output Yes\texttt{Yes}. Otherwise output No\texttt{No}.

3
7 4
4 0
2 2
7 1
5 1
3 2
2 2
3 1
3 1
3 100
Yes
No
No

Hint

For the first sample test case, pressing buttons in the order of ++cc+c+ can satisfy all known conditions.

For the second sample test case, there are 88 ways to press the buttons 33 times.

$$\begin{array}{|c|c|c|c|c|c|c|} \hline \textbf{Presses} & \textbf{$2$-nd Op. Result} & \textbf{$3$-rd Op. Result} & & \textbf{Presses} & \textbf{$2$-nd Op. Result} & \textbf{$3$-rd Op. Result} \\ \hline ccc & 0 & 0 & & +cc & 0 & 0 \\ \hline cc+ & 0 & 1 & & +c+ & 0 & 1 \\ \hline c+c & 1 & 0 & & ++c & 2 & 0 \\ \hline c++ & 1 & 2 & & +++ & 2 & 3 \\ \hline \end{array}$$

There is no way to satisfy all known conditions.

For the third sample test case, pressing the buttons 33 times can only make the value on the counter at most 33. It can't be 100100.