#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t[100005],x[100005];
set<ll> st;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int n;
		scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%lld%lld",&t[i],&x[i]); 
		t[n+1]=INT_MAX;
		t[n+1]+=t[n+1];
		ll tm=0,ans=0,pos=0,l=0,r=0,ltm=0,f=1,lpos=0;
		for(int i=1;i<=n;i++)
		{
			if(t[i]>=tm)  
			{
				ll d1=0;
				ll d2=d1+t[i+1]-t[i];
				if(x[i]>=pos)
				{
					f=1;
					l=pos+d1;
					r=pos+d2;
				}
				else
				{
					f=-1;
					r=pos-d1;
					l=pos-d2;
				}
//				cout<<l<<" "<<r<<" "<<tm<<"\n";
				if(x[i]>=l&&x[i]<=r) ans++;
				ltm=t[i];
				tm=t[i]+llabs(pos-x[i]);
				lpos=pos;
				pos=x[i];
			}
			else
			{
				ll d1=t[i]-ltm;
				ll d2=min(tm,t[i+1])-ltm;
				if(f==1)
				{
					l=lpos+d1;
					r=lpos+d2;	
				}
				else
				{
					r=lpos-d1;
					l=lpos-d2;	
				}	
//				cout<<l<<" "<<r<<" "<<tm<<"\n";
				if(x[i]>=l&&x[i]<=r) ans++;
			}	
		}
		printf("%lld\n",ans);
	}
} 
/*
1
8
1 1
2 -6
7 2
8 3
12 -9
14 2
18 -1
23 9
*/