#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
ll t[maxn], x[maxn];
int main()
{
    int T;
    cin >> T;
    while(T--)
    {
    	int n;
	    cin >> n;
	    for(int i = 1; i <= n; ++i) cin >> t[i] >> x[i];
	    t[n+1] = 1e12;
	    int ans = 0;
	    int pos = 0, target = 0;
	    for(int i = 1; i <= n; ++i) 
		{
	        if(pos == target) target = x[i];
	        ll d = t[i+1] - t[i];
	        ll sum = abs(pos - target); 
	        if(target >= pos && pos <= x[i] && min(pos + d, (ll)target) >= x[i]) ++ans;
	        else if(target <= pos && pos >= x[i] && max(pos - d, (ll)target) <= x[i]) ++ans;
	        if(target >= pos) pos += min(d, sum);
	        else pos -= min(d, sum);
	    }
	    cout<<ans<<endl;
	}
    return 0;
}