Complete Your Task

Sara_Hasan Replay of Ada Lovelace Na...
Limits 2s, 512 MB

There are NN girls in a class, having roll numbers from 11 to NN. Each of them has some points PiP_i & a task. The task requires PrP_r points to complete. A girl can use her own points & points from her previous roll girl to complete her task. ( Roll 11 can use her points & points from roll NN girl.)

Now you have to check whether all the girls can complete their tasks or not.

Input

The first line contains a single integer TT ( 1T1041 \leq T \leq 10^4 ) — the number of test cases.

The first line of each test case contains the single integer NN ( 1N1061 \leq N \leq 10^6) — the number of girls in a class.

Each of the next NN lines contains 22 integers, PrP_r and PiP_i( 1Pr,Pi109,1i=rN1 \leq P_r, P_i \leq 10^9, 1 \le i = r \le N )

It's guaranteed that the sum of NN over all test cases doesn't exceed 10610^6.

Output

For each test case, print YESYES, if all the girls can complete their task, or NONO otherwise.

Sample

InputOutput
5
4
7 3
5 7
2 6
3 3
4
7 3
5 3
2 6
3 7
2
1000000000 1000000000
1000000000 999999999
6
7 8
5 10
2 1
3 4
9 8
2 1
9
7 5
6 8
7 6
10 8
5 6
7 9
10 10
8 1
7 13
NO
YES
NO
YES
NO

Submit

Login to submit.

Statistics

43% Solution Ratio
Ashiqur.141492Earliest, 2M ago
steinumFastest, 0.0s
IU_SpiralForgeLightest, 5.4 kB
IU_SpiralForgeShortest, 889B
Toph uses cookies. By continuing you agree to our Cookie Policy.