Diamonds

No attempts yetTime limit5sMemory limit256 MB

Problem

The value of a diamond is set by its weight in carats and by its clarity. A small clear diamond is worth more than a large cloudy one. Clarity uses a scale from 0.0 to 10.0, where 0.0 is a perfectly clear diamond and 10.0 is the most flawed one.

You are given the weight wiw_i and the clarity cic_i of NN diamonds in the order they appear in the input. Keeping that order, find the maximum length of a subsequence whose weight keeps growing while the clarity value keeps falling. If the chosen indices are i1<i2<<iki_1 < i_2 < \cdots < i_k, then every adjacent pair must satisfy wij<wij+1w_{i_j} < w_{i_{j+1}} and cij>cij+1c_{i_j} > c_{i_{j+1}}. Neither condition allows equal values.

Consider this input data.

wiw_icic_i
1.59.0
2.02.0
2.56.0
3.05.0
4.02.0
10.05.5

The longest subsequence that satisfies the condition has length 4 and consists of these four diamonds.

wiw_icic_i
1.59.0
2.56.0
3.05.0
4.02.0

The weight keeps growing and the clarity value keeps falling.

Input

The first line has the number of test cases TT (1T1001 \le T \le 100). Each test case starts with a line holding the number of diamonds NN (1N2001 \le N \le 200). The next NN lines each hold the weight wiw_i and the clarity cic_i of one diamond, separated by a space (0wi,ci1000 \le w_i, c_i \le 100).

Output

For each test case, print on its own line the length of the longest subsequence whose weight increases and whose clarity value decreases.