#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll min1(ll t1,ll t2){
    if(t1>t2)return t2;
    return t1;
}
ll max1(ll t1,ll t2){
    if(t1>t2)return t1;
    return t2;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	int t1;cin>>t1;
	while(t1--){
	    ll n;cin>>n;
	    ll t[n+1],x[n+1];
	    t[n] = 3000000000;
	    for(int i=0;i<n;i++){
	        ll t1,x1;cin>>t1>>x1;
	        t[i]=t1;x[i]=x1;
	    }
	    ll tstart = 0,tend = 0,xstart = 0,xend = 0,speed = 0,c=0;
	    for(int i=0;i<n;i++){
	        if(t[i]>=tend){
	            xstart = xend;
	            xend = x[i];
	            if(xend>xstart)speed=1;
	            else if(xend<xstart)speed=-1;
	            else speed=0;
	            tstart = t[i];
	            tend = speed*(xend-xstart)+tstart;
	        }
	        ll x1 = speed*(t[i]-tstart)+xstart,x2 = speed*(min1(t[i+1],tend)-tstart)+xstart;
	       // cout<<"dist "<<x1<<" "<<(min1(t[i+1],tend))<<"\n";
	        if(x[i]>=min1(x1,x2) && x[i]<=max1(x1,x2))c++;
	    }
	    cout<<c<<"\n";
	}
}