#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
ll _,n,t[maxn],x[maxn],pos[maxn];
int main(){
	_=read();
	while(_--){
		n=read();
		for(int i=1;i<=n;++i){
			t[i]=read();
			x[i]=read(); 
		}
		ll ans=0,ex=0,et=0;
		for(int i=1;i<=n;++i){
			if(t[i]>=et){
				pos[i]=ex;
				et=t[i]+abs(x[i]-ex);
				ex=x[i];
			}
			else pos[i]=pos[i-1]+(t[i]-t[i-1])*(ex>pos[i-1]?1:-1);
		}
		pos[n+1]=ex;
		for(int i=1;i<=n;++i){
			ll l=pos[i],r=pos[i+1];
			if(l>r) swap(l,r);
			if(x[i]>=l&&x[i]<=r) ++ans;
		}
		printf("%lld\n",ans);
	}
    return 0;
}
