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

int main(){
    int t;
    cin>>t;
    while(t--){
        long long int pos = 0, dr = 0, lft = 0, n = 0, cnt = 0;
        cin>>n;
        vector<pair<long long int, long long int>>v(n);
        for(int i=0; i<n; i++)
            cin>>v[i].first>>v[i].second;
        v.push_back({4e9, 0});

        for(int i=0; i<n; i++){
            long long int tm = v[i].first, x = v[i].second, tn = v[i+1].first;
            if(lft == 0){
                lft = abs(pos - x);
                if(lft>0)
                    dr = (x - pos)/lft;
            }
            long long int tmp = min(lft, tn-tm);
            if(x>=min(pos, pos+dr*tmp) && x<=max(pos, pos+dr*tmp))
                cnt++;
            pos += (dr*tmp);
            lft -= tmp;
        }
        cout<<cnt<<'\n';
    }
}