#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
#define pb push_back
#define db double
#define int ll
using namespace std;
const int maxn = 1000001, inf = 2147483647;
const ll mod = 0 ? 998244353 : 1000000007, linf = 9223372036854775807;
const double pi = acos(-1);
inline ll mi(ll a, ll b, ll mm = mod) { a %= mm; ll u = 1; while (b) { if (b & 1)u = u * a % mm; a = a * a % mm, b >>= 1; }return u; }
inline ll gcd(ll a, ll b) { ll c = a % b; while (c)a = b, b = c, c = a % b; return b; }
inline void mem(int* a, int p = 0, int len = maxn) { for (int i = 0; i < len; i++)a[i] = p; }
struct p {}e[maxn];
static bool cmp(int i, int j) { return i > j; };
int t, n, m, a[maxn], x;
int ans = 0, b[maxn], su;
string s;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);//sf和cin混用会出错
	cin >> t;
	while (t--) {
		cin >> n;
		for (int i = 0; i < n; i++)
			cin >> a[i] >> b[i];
		x = 0, ans = 0;
		for (int i = 0; i < n; i++) {
			if (i==n-1||abs(x - b[i]) <= a[i + 1] - a[i])
				ans++, x = b[i];
			else {
				int j = i;
				while (j+1<n&&abs(x - b[i]) > a[j + 1] - a[i])
					j++;
				for (int ii = i + 1; ii <= j; ii++) {
					if (b[i] > x) {
						if (ii == n - 1)
							m = b[i];
						else
							m = min(b[i], a[ii + 1] - a[i] + x);
						if (a[ii] - a[i] + x <= b[ii] && m >= b[ii])
							ans++;
					}
					else {
						if (ii == n - 1)
							m = b[i];
						else
							m = max(b[i], -a[ii + 1] + a[i] + x);
						if (-a[ii] + a[i] + x >= b[ii] && m <= b[ii])
							ans++;
					}
				}
				x = b[i];
				i = j;
			}
		}
		cout << ans<<endl;
	}
}


