#include<iostream>#include<algorithm>#include<string.h>using namespace std;struct Machine{int l, w;}data[5010];bool use[5010]; //标记木棒是否用过:1用过,0未用过bool operator < (const Machine a, const Machine b) //将木棒排序 长度递增 若相等则重量递增{if(a.l == b.l)return a.w < b.w;return a.l < b.l;}int main(){//freopen("1.txt","r",stdin);int t;cin>>t;while(t--){memset(use, 0, sizeof(use));int n, count = 0;Machine last;cin>>n;for(int i = 0; i < n; ++i){cin>>data[i].l>>data[i].w;}sort(data, data + n); //木棒排序for(int i = 0; i < n; ++i) //对第i个木棒 求递增子序列{last.w = data[i].w; //记录新序列的开始if(!use[i]){for(int j = i + 1; j < n; j++){if(last.w <= data[j].w && !use[j]) //l已经排序 不需要比较{use[j] = 1; //用到则标记为1last.w = data[j].w; //队尾元素}}count++; //子序列结束后,时间加1.计算第i + 1个木棒}}cout<<count<<endl;}return 0;}


