/*
@author: Saurav Sihag
*/

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define lld long double

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}


void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d", &v[i]);
}

// const int nax=1e+5+5;
// const int inf=1e+9+5;
const ll mod=1e+9+7;
// const ll mod=998244353;
const ll nax=1e+16+5;
// const int dx[4]={0,0,-1,1};
// const int dy[4]={1,-1,0,0};



void sol(){
    int n;
    cin>>n;
    vector<pair<ll, ll>> vp(n);
    for (int i=0; i<n; ++i){
        // scanf("%lld %lld", &vp[i].ff, &vp[i].ss);
        cin>>vp[i].ff>>vp[i].ss;
    }
    vp.push_back({nax, INT_MAX});
    int res=0;
    ll curr=0, aim=0, x, y, z;
    for (int i=0; i<n; ++i){
        if (aim==curr){
            aim=vp[i].ss;
            x=abs(aim-curr);
            y=vp[i+1].ff-vp[i].ff;
            if (y>=x) res++;
            if (aim>curr) curr=min(aim, curr+y);
            else curr=max(aim, curr-y);
        }
        else{
            // cout<<"i="<<i<<" curr="<<curr<<" aim="<<aim<<endl;
            x=abs(vp[i].ss-curr);
            y=vp[i+1].ff-vp[i].ff;
            // z=aim-curr;
            if (y>=x && ((vp[i].ss<=aim && curr<=vp[i].ss) || (vp[i].ss>=aim && curr>=vp[i].ss)))res++;
            if (aim>curr) curr=min(aim, curr+y);
            else curr=max(aim, curr-y);
        }
        // cout<<"i="<<i<<" res="<<res<<endl;
    }
    printf("%d\n", res);
}



int main() {
    int t;
    // t=1;
    cin>>t;
    t++;
    // std::cout << std::setprecision(20);
    for (int i=1; i<t; ++i){ 
        // printf("Case #%d: ", i);
        sol();
    }
    return 0;
}