// this is my code please tell me the problem
#include
using namespace std;
int main() {
int t,n,i,j,k=1;
int arr[1000][1000];
cin>>t;
while(t>0)
{ k=1;
cin>>n;
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
cin>>arr[i][j];
}
int m=1;
for(i=0;i<n&&m<n;)
{
if(arr[i][1]<=arr[m][0])
{
k++;
i=m;
m++;
}
else
{
m++;
}
}
t–;
cout<<k<<endl;
}
return 0;
}