Diamonds
A diamond's overall worth is determined by its mass in carats as well as its overall clarity. A large diamond with many imperfections is not worth as much as a smaller, flawless diamond. The overall clarity of a diamond can be described on a scale from 0.0 - 10.0 adopted by the American Gem Society, where 0.0 represents a flawless diamond and 10.0 represents an imperfect diamond.
Given a sequence of n diamonds, each with weight, w[i]
, in carats and clarity c[i]
, on the scale described above, find the longest subsequence of diamonds for which the weight and clarity are both becoming strictly more favorable to a buyer.
In the following sequence of diamonds
the longest desirable subsequence is
because the weights strictly increase while the clarities strictly decrease.
Input
Starts with a line with a number of test cases t (1 ≤ t ≤ 100). Each test case begins with a line with a single integer n (1 ≤ n ≤ 200), indicating the number of diamonds. Next follow n lines with 2 real numbers w[i]
and c[i]
, (0.0 ≤ w[i]
, c[i]
≤ 10.0), indicating the weight in carats and the clarity of diamond i respectively.
Output
For each test case, print a single line with the length of the longest desirable subsequence of diamonds.