#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
ll t[maxn],x[maxn];
void solve(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++) scanf("%lld%lld",&t[i],&x[i]);
  t[n]=1e18+5;
  ll in=0,ti=0,f=0,ans=0;
  for(int i=0;i<n;i++){
    if(ti>0){
      ll in2=in;
      ll tmp=min(t[i+1]-t[i],ti);
      in+=f*(tmp);
      ti-=tmp;
      if(x[i]<=max(in2,in)&&x[i]>=min(in2,in)) ans++;
    }
    else {
      if(x[i]<in){
        f=-1;
        ti=abs(x[i]-in);
        i--;
      }
      else if(x[i]>in){
        f=1;
        ti=abs(x[i]-in);
        i--;
      }
      else {
        ans++;
      }
    }
  }
  printf("%lld\n",ans);
}
int main(){
  int _;scanf("%d",&_);
  while(_--) solve();
  return 0;
}