#include <bits/stdc++.h>
using namespace std;
#define ll long long
/*
#include <limits.h>
INT_MAX
LLONG_MAX
*/

const int N = 1e5+15;

ll t[N],x[N];

bool isInside(ll a,ll b,ll c) {
  if(a>b) swap(a,b);
  return a<=c && c<=b;
}

void solve2() {
  int n;
  scanf("%d ", &n);
  int ret = 0;
  ll position = 0,target = 0;
  for(int i=0;i<n;++i) {
    scanf("%lld %lld ", &t[i],&x[i]);

    if(i!=0) {
      ll nposition, dist = abs(target-position);
      dist = min(dist, t[i]-t[i-1]);
      if( target-position <0) {
        dist *= -1;
      }
      nposition = position + dist;

      if(isInside(position,nposition,x[i-1])) {
        ++ret;
      }
      position = nposition;
    }
    if(target==position) {
      target = x[i];
    }
  }

  if(isInside(position,target,x[n-1])) {
    ++ret;
  }
  printf("%d\n",ret);
}

void solve() {
  int n;
  scanf("%d ", &n );
  while(n--) {
    solve2();
  }
}

int main() {
  // freopen("input.txt","r",stdin);
  solve();
  return 0;
}
