#Lutece0124. Tournament

Tournament

Migrated from Lutece 124 Tournament

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

A sports company is planning to advertise in a tournament. It is a single round-robin tournament, that's to say competitors play with all the others once. The company thinks that the advertising impact is proportional to the so called competitiveness degree(CD) of the tournament.

CD is calculated in the following way: We assume there're NN competitors in the tournament and of course N×(N1)2\frac{N\times (N - 1)}{2} matches in total. For each competitor we define two values SS and EE which stand for skill and experience. We say a match between competitor ii and competitor jj is competitive if and only if Si+EiSjS_i + E_i \geq S_j and Sj+EjSiS_j + E_j \geq S_i. CD equals to the number of competitive matches among all N×(N1)2\frac{N\times (N - 1)}{2} matches in the tournament.

Input

One integer TT (T20T \leq 20) on the first line indicates the number of cases. The first line of each case contains one integer NN (1N100001\leq N\leq 10000) -- the number of competitors. Then NN lines follows. The ithi_{th} line contains two integer SiS_i and EiE_i (1Si,Ei1000000001\leq S_i, E_i\leq 100000000) which are defined in the description.

Output

For each case, print the value of CD on a line.

Samples

3
2
1 2
4 1
2
1 2
2 2
5
1 9
5 4
3 4
2 2
6 2
0
1
8

Resources

The 8th UESTC Programming Contest Final