#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <assert.h>
#include <unordered_map>
#include <math.h>
using namespace std;

#define ll long long
#define ld double
#define endl "\n"
const ll mod = 1e9 + 7;
const int MX = 100005;

int main(){
	cin.tie(0) -> sync_with_stdio(0);
	
	int tc; cin >> tc;
	for(int n; tc --;){
		cin >> n;
		vector<ll> t(n), x(n);
		for(int i = 0; i < n; i ++)
			cin >> t[i] >> x[i];
		t.push_back(mod * 1ll * mod);

		int cnt = 0, ps = 0, cr = mod;
		for(int i = 0; i < n; i ++){
			int lf = ps, rg = ps;
			if(cr == mod) cr = x[i];

			int tp = min((ll)abs(ps - cr), t[i + 1] - t[i]);
			if(ps < cr) ps += tp;
			else ps -= tp;

			lf = min(lf, ps); rg = max(rg, ps);
			if(ps == cr) cr = mod;

			if(lf <= x[i] && x[i] <= rg) cnt ++;
		}

		cout << cnt << endl;
	}
	
	return 0;
}