#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define inf 1e17
#define endl '\n'
using namespace std;
bool btw(ll a,ll b, ll c){
	if(a>=min(b,c) && a<=max(b,c))return true;
	else return false;
}
bool check(ll tu,ll curst,ll curen,ll pt,ll t[],ll x[],ll n){
		ll tfin=inf;
		if(pt!=n-1)tfin=t[pt+1];
		ll td=abs(curst-x[pt]);
		if( ((tu+td)>=t[pt]) && btw(x[pt],curst,curen) && (tu+td<=tfin) )	return true;
		else return false;
}
void run(){
	 
	ll n;cin>>n;
    ll t[n],x[n];
    for(ll i=0;i<n;i++)	cin>>t[i]>>x[i];
    ll c=0;
    
    ll tu=t[0];
    ll pt=0;
    
    ll curst=0;
    ll curen=x[0];
    
    while(pt<n){
    	
    	while(pt<n && tu+abs(curen-curst)  > t[pt]){
    		// ignore
    		if(check(tu,curst,curen,pt,t,x,n)){
    			c++;
    		}
    		pt++;
    	}
    	if(curst==curen){pt++;c++;}
    	if(pt<n && tu+abs(curen-curst)  <= t[pt]){
    		tu=t[pt];
    		curst=curen;
    		curen=x[pt];
    	}
    }
    cout<<c<<endl;
    
}
int main() {
	 ios_base::sync_with_stdio(false);
	      cin.tie(NULL);
	ll t=1;
	cin>>t;
	for(ll i=0;i<t;i++)run();
	// your code goes here
	return 0;
}