Time Limit: 1000 MS    Memory Limit: 65536 K 


Description

There is such a policy in Sichuan University that if you are not satisfied with the score of your course, you can study this course again to get a better score. If you do this and get a higher score(than the highest score he got before), it can cover the original one. And we can say this time you update the score of this course successfully. Here is one schoolmate's all the courses he has studied and scores he got (sorted by chronological order). So could you tell me how many time he successfully update his scores of courses?

Input

The first of input is an integer T which stands for the number of test cases. For each test case the first line is an integer N (1 <= N <= 100) which stands for the number of courses he has studied.Then following N lines, each line contains a string (only contains letters and the length is no more than 30,which stands for the course name) and an integer (0<=integer<=100, which stands for the score of the course), separated by a space.

Remember: the best way is getting the best score in one time. Study one course many times is not a recommended choice!

Output

For each test case output the number of times he update successfully.

Sample Input

2 6 CProgramming 70 DataStructrue 80 CProgramming 80 CProgramming 60 CProgramming 90 DataStructrue 70 2 CompilerTheory 95 Network 90

Sample Output

2 0

Author

wwr&fengzlzl

Source

Sichuan University Programming Contest 2011 Preliminary