#include<bits/stdc++.h>
using namespace std;
#define dd double
#define ll long long int 
#define light ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_pair pair<ll,pair<ll,ll>> 
ll INF=1e9+5;
ll mod=998244353;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif

	light;
	ll q;
	cin>>q;
	while(q--){
		ll n;
		cin>>n;
		vector<ll>t(n+1),x(n);
		for(ll i=0;i<n;i++){
			cin>>t[i]>>x[i];
		}
		t[n]=INF;
		vector<ll>now(n+1);
		ll curr=0,next=0,time=0;
		for(ll i=0;i<n;i++){
			if(t[i]<time){
				ll direction=next-curr;
				if(direction>=0){
					curr+=(t[i]-t[i-1]);
				}
				else{
					curr-=(t[i]-t[i-1]);
				}
			}
			else{
				curr=next;
				next=x[i];
				time=t[i]+abs(x[i]-curr);
			}
			now[i]=curr;
		}
		now[n]=next;
		ll ans=0;
		for(ll i=0;i<n;i++){
			ll a=now[i];
			ll b=now[i+1];
			if(a>b){
				swap(a,b);
			}
			if(x[i]>=a && x[i]<=b){
				ans++;
			}
		}
		cout<<ans<<"\n";
	}
}