#d2957. nice party
nice party
Nice Party
Problem Description
cc is going to throw a party and invites his friends so that everyone has a good time.
cc has friends; the -th friend has net worth .
The -th friend will attend the party and enjoy it if and only if there are at most people present whose net worth is strictly greater than his, and at most people whose net worth is strictly smaller than his.
cc wants to know: what is the maximum number of friends he can invite such that every invited friend enjoys the party?
Input Format
The first line gives an integer , the number of test cases ().
For each test case:
- The first line gives an integer (), the number of friends.
- The following lines each give two integers and ().
Output Format
For each test case, output one integer: the maximum number of friends cc can invite.
Sample Input
3
3
1 2
2 1
1 1
2
0 0
0 1
2
1 0
0 1
Sample Output
2
1
2