#include <bits/stdc++.h>

const int N = 100010;
const long long INF = 1ll<<60;
const int inf = 0x3f3f3f3f;
typedef std::pair<int, int> PairInt;
typedef std::pair<long long, int> Pair;
const long long mod = 1e9 + 7;

int t;
int n, m;
long long a[N];
long long b[N];

int ReadInt() {
  int x = 0, f = 1; 
  char ch = getchar();
  while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
  while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
  return x * f;
}

long long Abs(long long x) {
  if (x < 0) return -x;
  else return x;
}

int main() {
  scanf("%d", &t);
  while (t --) {
    n = ReadInt();
    for (int i = 1; i <= n; ++i) {
      a[i] = ReadInt();
      b[i] = ReadInt();
    }
    long long last = 0;
    int ans = 0;
    a[n + 1] = INF;
    for (int i = 1, j = 1; i <= n; i = j) {
      if (last == b[i]) {
        ++ans;
        ++j;
        continue;
      }
      long long t_end = a[i] + Abs(last - b[i]);
      while (j <= n && a[j] < t_end) {
        if((b[j] >= last && b[j] <= b[i]) || (b[j] >= b[i] && b[j] <= last)) {
          long long t_arrive = a[i] + Abs(b[j] - last);
          if (t_arrive >= a[j] && t_arrive <= a[j + 1]) {
            ++ans;
          }
        }
        ++j;
      }
      last = b[i];
    }
    printf("%d\n", ans);
  }

  return 0;
}