Attack Order
Time limit2sMemory limit512 MB
Given minions with attacks a_i and buff values b_i, decide whether some left-to-right order keeps attacks non-increasing for every possible choice of buff targets.
Problem
In a certain game, you control a board of minions numbered from to . Each minion has an integer , called its attack.
For the upcoming fight, you arrange the minions in a line from left to right.
After that, some of the minions' attacks get buffed. The ability of each minion reads "Before the fight, increase the attack of another random minion by ". Formally, for each , an arbitrary minion is chosen and its attack is increased by .
The buff targets are chosen independently and the buffs happen simultaneously. In particular, the attack of any minion can get buffed multiple times.
You want the attacks of the minions to be non-increasing from left to right after all the buffs happen. Determine whether it is possible to arrange the minions so that this holds regardless of how the buff targets are chosen.
Input
Each input contains multiple test cases. The first line contains the number of test cases (). The test cases follow.
The first line of each test case contains a single integer ().
The -th of the next lines contains two integers and ().
Output
For each test case, print "Yes" if it is possible to arrange the minions so that their attacks are non-increasing regardless of how the buff targets are chosen, and "No" otherwise.
Notes
In the first example, the minions buff each other. The attacks of minions and during the fight are always and , respectively. You can arrange the minions in the order .
In the second example, only minion buffs another minion. One valid ordering is . If minion buffs minion , the attacks of the minions, from left to right, are . If minion buffs minion , the attacks are . Both sequences are non-increasing.