#d1803. 排列
排列
Permutation
Problem Description
There are knights, with initial attack powers . Each knight also has a buff ability .
For each knight, he will choose some other knight (not himself) and increase that knight's attack power by .
Determine whether there exists a permutation of the knights such that, no matter how each knight chooses the target of his buff, the attack powers of the knights are non-increasing from left to right.
Input Format
The first line contains a positive integer , the number of test cases.
For each test case, the first line contains a positive integer , the number of knights.
Each of the next lines contains two integers: the -th line contains and , the initial attack power and buff ability of knight .
Output Format
For each test case, if there exists a permutation of the knights satisfying the requirement, output Yes; otherwise output No.
Sample Input
3
2
15 25
10 5
3
7 0
7 3
10 0
3
10 10
20 20
30 30
Sample Output
Yes
Yes
No
Sample Explanation
For the first test case, since , the final attack powers must be and . It is clearly possible.
For the second test case, we can arrange the knights as , placing the knight with buff ability last. Then no matter how the knight with buff ability chooses, the requirement is satisfied.
For the third test case, it can be proven that no arrangement satisfies the requirement, so output No.
Constraints
For all data, , , and .