//18minutes
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
#define all(x) x.begin(), x.end()

void solve() {
   int n;
   cin >> n;
   vector <pair <ll, ll>> p(n);
   for (auto &i : p) {
      cin >> i.ff >> i.ss;
   }
   p.push_back({1e17, 0});
   ll cr = 0, pr = 0, tm = 0, good = 0;
   for (int i = 0; i < n; i++) {
      if (tm <= p[i].ff) {
         pr = cr;
         cr = p[i].ss;
         tm = p[i].ff + abs(pr - cr);
      }
      ll sm = tm - abs(pr - cr) + abs(p[i].ss - pr);
      if (min(pr, cr) <= p[i].ss && p[i].ss <= max(pr, cr) && p[i].ff <= sm && sm <= p[i + 1].ff)
         good++;
   }
   cout << good << '\n';
}

int main() {
#ifndef ONLINE_JUDGE
   freopen("E:\\inp.txt", "r", stdin);      freopen("E:\\outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   int t;
   cin >> t;
   while (t--)
      solve();

   return 0;
}