#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 competitors in the tournament and of course matches in total. For each competitor we define two values and which stand for skill and experience. We say a match between competitor and competitor is competitive if and only if and . CD equals to the number of competitive matches among all matches in the tournament.
Input
One integer () on the first line indicates the number of cases. The first line of each case contains one integer () -- the number of competitors. Then lines follows. The line contains two integer and () 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