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 wi and the clarity ci of N 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<⋯<ik, then every adjacent pair must satisfy wij<wij+1 and cij>cij+1. Neither condition allows equal values.
Consider this input data.
| wi | ci |
|---|---|
| 1.5 | 9.0 |
| 2.0 | 2.0 |
| 2.5 | 6.0 |
| 3.0 | 5.0 |
| 4.0 | 2.0 |
| 10.0 | 5.5 |
The longest subsequence that satisfies the condition has length 4 and consists of these four diamonds.
| wi | ci |
|---|---|
| 1.5 | 9.0 |
| 2.5 | 6.0 |
| 3.0 | 5.0 |
| 4.0 | 2.0 |
The weight keeps growing and the clarity value keeps falling.
The first line has the number of test cases T (1≤T≤100). Each test case starts with a line holding the number of diamonds N (1≤N≤200). The next N lines each hold the weight wi and the clarity ci of one diamond, separated by a space (0≤wi,ci≤100).
For each test case, print on its own line the length of the longest subsequence whose weight increases and whose clarity value decreases.