#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100002;
const int max_n = 2e9;
ll t,n,ti[N],x[N];
int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cin>>t;
    while(t--){
        cin>>n;
        ll et = 0,tar=0,res=0;
        for(int i=1;i<=n;i++){
            cin>>ti[i]>>x[i];
        }
        ti[n+1] = max_n;
        int flag = 1;
        for(int i=1;i<=n;i++){
            if(et<=ti[i]){
                flag = 1;
                if(x[i]<tar){
                    flag = -1;
                }
                if(abs(tar-x[i])<=ti[i+1]-ti[i] || i==n){
                    res++;
                }
                et = ti[i]+abs(tar-x[i]);
                tar = x[i];
            }else{
                ll be = tar-flag*(et-ti[i]);
                ll en  = 0;
                if(flag>0){
                    en = min(tar,tar+(ti[i+1]-et));
                }else{
                    en = max(tar,tar-(ti[i+1]-et));
                }
                if(i==n) en = tar;
                if(x[i]>=min(be,en)&&x[i]<=max(be,en)){
                    res++;
                }
            }
        }

        cout<<res<<endl;
    }


    return 0;
}
