// C. Busy Robot
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	cin.tie(0)->sync_with_stdio(0);
	int T;
	cin >> T;
	while (T--) {
		int n;
		cin >> n;
		vector<long long> t(n), x(n);
		for (int i = 0; i < n; i++) cin >> t[i] >> x[i];
		long long ans = 0, p = 0, q = 0, c = 0;
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				c = t[i];
				q = x[i];
			} else {
				if (t[i] >= c + abs(q - p)) {
					c = t[i];
					p = q;
					q = x[i];
				}
			}
			if (p <= q) {
				long long pp = p + (t[i] - c);
				long long qq = min(q, p + ((i + 1 < n ? t[i + 1] : 1000000000000) - c));
				// cout << i << ": " << pp << ", " << qq << " | " << p << ", " << q << endl;
				if (x[i] >= pp && x[i] <= qq) ans++;
			} else {
				long long pp = p - (t[i] - c);
				long long qq = max(q, p - ((i + 1 < n ? t[i + 1] : 1000000000000) - c));
				// cout << i << ": " << pp << ", " << qq << " | " << p << ", " << q << endl;
				if (x[i] >= qq && x[i] <= pp) ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}
