#include<bits/stdc++.h> 
using namespace std; 
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lli long long int
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define pll pair<lli,lli>
#define ve vector<lli>
#define vep vector<pair<lli,lli> >
#define fr(i,a,n) for(lli i=a;i<(n);i++)
#define frx(i,a,n) for(lli i=a;i>(n);i--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define db(x) cout << "[ " << x << " ]" << endl
#define db2(x,y) cout<<"[ " <<x<<" "<<y<< " ]" <<endl
#define parr(arr,a,n) fr(i,a,n) cout<<arr[i]<<" "; cout<<endl
#define mem(a,x) memset(a,x,sizeof(a));
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl


void solve(){
    lli n;
    cin>>n;
    lli from=0,to=0,rtime=0,ans=0;
    lli t[n+5],x[n+5];
    fr(i,0,n)cin>>t[i]>>x[i];
    t[n]=1e12;
    fr(i,0,n){
        if(rtime<=t[i]){
            from=to;
            to=x[i];
            rtime=t[i]+abs(to-from);
            if(abs(to-from)<=t[i+1]-t[i]){
                ans++;
            }
        }
        else{
            lli sign=1;
            if(to<from)sign=-1;
            lli c1=to-(rtime-min(rtime,t[i+1]))*sign,c2=to-(rtime-t[i])*sign;
            if(c1>c2)swap(c1,c2);
            if(c1<=x[i] && x[i]<=c2){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    fast;
    lli t=1;
    cin>>t;
    while(t--){
        solve();
    }
}