#include<bits/stdc++.h>
using namespace std ;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long int
#define endl '\n'
#define whatis(x) cout<<#x<<" is "<<x<<endl;


//int divi(int a, int b){
//    return(mul(a, power(b, mod - 2)) % mod);
//}



signed main()
{
    fast;
    int tt = 1 ;
    cin>>tt;

    while( tt-- > 0)
    {
        int n;
        cin>>n;
        int a[n] , t[n+1];
        int d = 1 , pos = 0 , time = 0 , lastx = 0;
        int ans = 0;
        for(int i=0;i<n;i++)
        {
            cin>>t[i]>>a[i] ;
        }
        t[n] = 1e18;
        for(int i=0;i<n;i++)
        {
            if(t[i]>=time)
            {
                time = abs(pos-a[i]) + t[i];
                if(a[i]>pos)
                    d = 1;
                else d = -1;
                pos = a[i];
                if(time<=t[i+1])
                    ans++;
            }
            else
            {
                int position = pos - (time-t[i])*d;
                int t_req = t[i] + abs(a[i]-position);
              //  whatis(position);
                //whatis(t_req);

                if(d==1&&t_req<=t[i+1]&&a[i]>=position&&a[i]<=pos)
                    ans++;

                if(d==-1&&t_req<=t[i+1]&&a[i]<=position&&a[i]>=pos)
                    ans++;

            }
           // whatis(time);

           // whatis(ans);

        }
       // cout<<t[n]<<' '<<INT_MAX<<endl;
        cout<<ans<<endl;
    }
        cerr << "\nTime elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}
