#include <bits/stdc++.h>

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<pair<long long,int>> P;
long long A[100001], B[100000];

int get_sign(long long a)
{
	return a<0 ? -1:a>0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int T, N;
	for(cin>>T;T--;) {
		int ans=0, j=0;
		cin>>N; P.clear(); P.emplace_back(0,0);
		for(int i=0;i<N;i++) cin>>A[i]>>B[i];
		A[N]=0x7fffffffffffLL;
		for(int i=0;i<N;i++) if(P.back().first<=A[i]) {
			P.emplace_back(A[i],P.back().second);
			P.emplace_back(A[i]+1LL*abs(P.back().second-B[i]),B[i]);
		}
		for(int i=0;i<N;i++) {
			while(j+1<P.size() && P[j+1].first<=A[i]) j++;
			if(j+1<P.size()) {
				int d=get_sign(P[j+1].second-P[j].second);
				if(d==0) {
					ans+=B[i]==P[j].second;
				}
				else if(d==1) {
					long long l=P[j].second+A[i]-P[j].first, r=P[j+1].second-(P[j+1].first-min(1LL*A[i+1],P[j+1].first));
					ans+=get_sign(B[i]-l)*get_sign(B[i]-r)<=0;
				}
				else {
					long long l=P[j].second-A[i]+P[j].first, r=P[j+1].second+P[j+1].first-min(1LL*A[i+1],P[j+1].first);
					ans+=get_sign(B[i]-l)*get_sign(B[i]-r)<=0;
				}
			}
			else if(P[j].second==B[i]) ans++;
		}
		cout<<ans<<'\n';
	}
	return 0;
}