#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =1e15;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    int t;cin>>t;
    while(t--)
    {
    	lli n;cin>>n;
    	vector<plli> cmds(n+1);
    	flli(i,0,n-1)
    	{
    		cin>>cmds[i].first>>cmds[i].second;
    	}
    	cmds[n]=mp(INF,INF);
    	lli ans=0;
    	plli poss=mp(0,0); //start,end pos
    	poss=mp(0,cmds[0].second);
    	int speed=0;
    	if(cmds[0].second>0)speed=1;
    	else if(cmds[0].second==0)speed=0;
    	else speed=-1;
    	flli(i,1,n)
    	{
    		lli timereq=0;if(speed!=0)timereq=(poss.second-poss.first)/speed;
    		lli timeval=0;if(speed!=0)timeval=(cmds[i-1].second-poss.first)/speed;
    		if(speed!=0 && timeval>=0 && cmds[i].first-cmds[i-1].first>=timeval && timeval<=timereq)
    		{
    			ans++;
    		}
    		else if(speed==0 && cmds[i-1].second==poss.first)
    		{
    			ans++;
    		}

    		if(cmds[i].first-cmds[i-1].first>=timereq)//it will accept new command
    		{
    			poss.first=poss.second;
    			poss.second=cmds[i].second;
    			if(poss.second>poss.first)speed=1;
    			else if(poss.second==poss.first)speed=0;
    			else speed=-1;
    			//cout<<i<<" "<<speed<<endl;
    		}
    		else
    		{
    			poss.first=poss.first+speed*(cmds[i].first-cmds[i-1].first);
    		}
    	}
    	cout<<ans<<endl;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}