#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll jdz(ll a){
	return a>0?a:-1*a;
}
struct com{
	ll t;
	ll x;
	ll len;
	ll poll;
	bool win;
};
com co[100005];
bool shuyu(ll a,ll b,ll c){
	if(b<=a&&a<=c||b>=a&&a>=c) return true;
	return false;
}
int main(){
	ll T;
	cin>>T;
	while(T--){
		memset(co,0,sizeof(co));
		ll n;
		cin>>n;
		for(ll i=1;i<=n;i++){
			cin>>co[i].t>>co[i].x;
		}
		co[1].win=true;co[1].len=jdz(co[1].x);co[1].poll=0;
		co[n+1].t=9223372036854775807;co[n+1].x=0;
		ll now=1;
		for(ll i=2;i<=n+1;i++){
			if(co[i].t-co[now].t>=co[now].len){//成功执行i 
				co[i].len=jdz(co[now].x-co[i].x);
				co[i].poll=co[now].x;
				now=i;
				co[i].win=true;
			}else{
				co[i].win=false;
				if(co[now].x>co[i-1].poll){
					co[i].poll=co[i-1].poll+(co[i].t-co[i-1].t);
				}else{
					co[i].poll=co[i-1].poll-(co[i].t-co[i-1].t);
				}
			}
			
		}
		/*
		for(ll i=1;i<=n+1;i++){
			cout<<(ll)co[i].win<<" "; 
		}
		cout<<endl;
		
		for(ll i=1;i<=n+1;i++){
			cout<<co[i].poll<<" "; 
		}
		cout<<endl;
		*/
		ll ans=0;
		for(ll i=1;i<=n;i++){
			if(shuyu(co[i].x,co[i].poll,co[i+1].poll)) ans++;
		}
		
		cout<<ans<<endl; 
		
	}
	
	
	
	
	return 0;
}