#P10852. 【MX-X2-T1】「Cfz Round 4」Awaken
【MX-X2-T1】「Cfz Round 4」Awaken
Background
Original link: https://oier.team/problems/X2A.
Can we wait until the moment the dream wakes up.

Problem Description
Yue had a dream. In the dream, she got an integer sequence of length , where .
Then she woke up. Yue forgot some elements of the sequence, leaving blanks. Luckily, Yue still remembers non-blank positions. Yue wants to fill in the blanks and restore the whole sequence.
Yue also remembers that the sequence in the dream had the following property: for all distinct indices satisfying , it always holds that .
Yue wants to know whether it is possible to restore a sequence that satisfies the property (if not, then she remembered it wrong). If possible, output Yes; otherwise output No.
Input Format
This problem has multiple test cases.
The first line contains an integer , the number of test cases.
Then each test case is given as follows:
- The first line contains two integers , where , and is the number of positions in that are not blank.
- The next lines each contain two integers , meaning that is not blank and . It is guaranteed that all are pairwise distinct.
Output Format
For each test case, output a string Yes or No, indicating whether the original sequence exists.
In this problem, the output is case-insensitive. That is, yes, yeS, yEs, Yes, YEs, YeS, yES, YES are all considered Yes, and similarly for No.
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
Yes
No
Yes
1
5 2
1 -2
5 -10
Yes
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
Yes
No
Hint
Sample Explanation #1
For the st test case, the current sequence is . One possible original sequence is . You can check that this sequence satisfies the property.
For the nd test case, the current sequence is . It can be proven that no original sequence satisfying the property exists. This sample reminds you that is not necessarily given in increasing order.
For the rd test case, the current sequence is . One possible original sequence is , and of course also works. This sample reminds you that can be , and the original sequence may contain negative numbers or .
Constraints
Let denote the sum of within a single test file.
For all testdata, , , , , , . It is guaranteed that within the same test case, all are pairwise distinct.
This problem uses bundled evaluation.
- Subtask 1 (20 points): and .
- Subtask 2 (30 points): , .
- Subtask 3 (20 points): .
- Subtask 4 (30 points): no special constraints.
Translated by ChatGPT 5