#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;

ll tmi[maxn], x[maxn];

void solve() {
	ll n,cur=0,pos=0,dest=0; cin >> n;
	ll ans=0;
	rep(i,0,n) cin >> tmi[i] >> x[i];
	tmi[n] = 1e12;
	rep(i,0,n) {
		if (abs(dest-pos)<=tmi[i]-cur) {
			pos = dest;
			cur = tmi[i];
			dest = x[i];
		} else {
			if (pos > dest) pos = max(dest, pos - (tmi[i] - cur));
			else pos = min(dest, pos + (tmi[i] - cur));
			cur = tmi[i];
		}
		if (pos > dest) {
			if (max(pos - (tmi[i+1]-cur), dest) <= x[i] && x[i] <= pos) ans++;
		} else {
			if (min(pos + (tmi[i+1]-cur), dest) >= x[i] && x[i] >= pos) ans++;
		}
		//z`cout << i << ' ' << ans << ' ' << cur << ' ' << pos << ' ' << dest << '\n';
	}
	cout << ans << '\n';
}

int main(int argc, char * argv[]) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int t; cin >> t; while(t--)
	solve();

    return 0;
}