Points

A point (x_1, y_1) is said to be less than or equal to (x_2, y_2) if x_1 ≤ x2 and y1 ≤ y2.

You're given a set of n points. You are asked to find a sequence of points contained in this set, which is non-decreasing by the definition given above. You have to find the longest such sequence.

Input

First line is number of testcases.
For each testcase: the first line contains n the number of points. This is followed by n lines describing the points.

Output

For each testcase output just one number: the length of the longest non-decreasing sequence.

Constraints

For 20 points: n ≤ 10^3 For another 80 points: n ≤ 10^5. Each point's coordinates are positive and ≤ 10^5.

Sample Input

2
4
1 1
2 2
3 3
4 4
4
1 1
1 2
2 2
2 1

Sample Output

4
3
CPU Timelimit: 5 seconds
Memory limit: 64M
Grading style: opc
Resource CMI Fiesta Onsite Programminc Contest 2008
Register Now

Running Contests

Search the archive: