#include <iostream>  
#include <map>
#include <math.h> 
#include <string>
#include <vector>
#include <algorithm> 
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <numeric>
#include <stack>

using namespace std;

int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(0); 
    long long t;
    cin>>t;
    while(t--){
        long long n,curr_t=0,curr_x=0,next_t=0,prev_x=0,ans=0;
        cin>>n;
        vector<long long>t(n),x(n);
        for(long long i=0;i<n;i++) cin>>t[i],cin>>x[i];
        for(long long i=0;i<n;i++){
            if( t[i] >= next_t ){
                prev_x = curr_x;
                curr_x = x[i];
                next_t = t[i]+abs(curr_x-prev_x);
                curr_t = t[i];
            }
            if( next_t == curr_t ) {ans++;continue;}
            long long check_t;
            // cout<<i<<endl;
            if( i < n-1 ) check_t = t[i+1];

            long long predx2;
            long long predx1 = prev_x + ((t[i]-curr_t)*(curr_x-prev_x))/(next_t-curr_t);
            if( i < n-1 ) predx2 = prev_x + ( (curr_x-prev_x) * (min(check_t,next_t)-curr_t) )/(next_t-curr_t);
            else predx2 = prev_x + ( (curr_x-prev_x) * (next_t-curr_t) )/(next_t-curr_t);

            if( min(predx1,predx2) <= x[i] && x[i] <= max(predx1,predx2) ) ans++;


            // cout<<curr_t<<" "<<next_t<<" "<<prev_x<<" "<<curr_x<<" "<<predx1<<" "<<predx2<<endl;
        }
        cout<<ans<<endl;
    }


    
}



