http://acm.nyist.net/JudgeOnline/problem.php?pid=14
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct Node{
int x,y;
} arr[10010];
bool cmp(const Node &a,const Node &b)
{
return (a.y<b.y)||((a.y==b.y)&&(a.x>b.x));
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&arr[i].x,&arr[i].y);
}
sort(arr+1,arr+n+1,cmp);
int sum=1;
int dy=arr[1].y;
for(int i=2;i<=n;i++)
{
if(arr[i].x>dy)
{
sum++;
dy=arr[i].y;
}
}
printf("%d\n",sum);
}
}