#P1915F. Greetings
Greetings
No submission language available for this problem.
Description
There are people on the number line; the -th person is at point and wants to go to point . For each person, , and the starting and ending points of all people are distinct. (That is, all of the numbers are distinct.)
All the people will start moving simultaneously at a speed of unit per second until they reach their final point . When two people meet at the same point, they will greet each other once. How many greetings will there be?
Note that a person can still greet other people even if they have reached their final point.
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the number of people.
Then lines follow, the -th of which contains two integers and () — the starting and ending positions of each person.
For each test case, all of the numbers are distinct.
The sum of over all test cases does not exceed .
For each test case, output a single integer denoting the number of greetings that will happen.
Input
The first line of the input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the number of people.
Then lines follow, the -th of which contains two integers and () — the starting and ending positions of each person.
For each test case, all of the numbers are distinct.
The sum of over all test cases does not exceed .
Output
For each test case, output a single integer denoting the number of greetings that will happen.
Note
In the first test case, the two people will meet at point and greet each other.