MDOLLS - Nested Dolls

题意翻译

迪沃斯是世界上最著名的俄罗斯套娃收藏家:你知道吗?他真的有成千上万的套娃!不同大小的空心木娃娃,最小的娃娃装在第二大的娃娃里,而这个娃娃又装在下一个娃娃里,等等。有一天,他想知道是否有另一种方式来嵌套它们,这样他就能减少套套玩偶的数量?毕竟,那会使他的收藏更加华丽!他打开每个嵌套的娃娃,测量每个娃娃的宽度和高度。当且仅当w1 < w2且h1 < h2时,宽度为w1且高度为h1的娃娃才能与另一个宽度为w2且高度为h的娃娃相匹配。你能帮他从他的大量测量数据中计算出最小的嵌套娃娃数量吗?

题目描述

[English](/problems/MDOLLS/en/) [Vietnamese](/problems/MDOLLS/vn/) ``` Dilworth is the world's most prominent collector of Russian nested dolls: he literally has thousands of them! You know, the wooden hollow dolls of different sizes of which the smallest doll is contained in the second smallest, and this doll is in turn contained in the next one and so forth. One day he wonders if there is another way of nesting them so he will end up with fewer nested dolls? After all, that would make his collection even more magnificent! He unpacks each nested doll and measures the width and height of each contained doll. A doll with width w1 and height h1 will fit in another doll of width w2 and height h= if and only if w1 < w2 and h1 < h2. Can you help him calculate the smallest number of nested dolls possible to assemble from his massive list of measurements? ```

输入输出格式

输入格式


``` On the first line of input is a single positive integer 1 ≤ t ≤ 20 specifying the number of test cases to follow. Each test case begins with a positive integer 1 ≤ m ≤ 20000 on a line of itself telling the number of dolls in the test case. Next follow 2m positive integers w1, h1,w2, h2, ... ,wm, hm, where wi is the width and hi is the height of doll number i. 1 ≤ wi, hi ≤ 10000 for all i. SAMPLE INPUT 4 3 20 30 40 50 30 40 4 20 30 10 10 30 20 40 50 3 10 30 20 20 30 10 4 10 10 20 30 40 50 39 51 ```

输出格式


``` For each test case there should be one line of output containing the minimum number of nested dolls possible. SAMPLE OUTPUT 1 2 3 2 ```

输入输出样例

暂无测试点