#include <bits/stdc++.h>   using namespace std;      const int INF = 0x3f3f3f3f;      int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<long long> t(n), x(n);       for (int i = 0; i < n; i++) {         cin >> t[i] >> x[i];       }       long long start = 0, end = 0, from = 0, to = 0, ans = 0;       for (int i = 0; i < n; i++) {         if (end <= t[i]) {           start = t[i];           end = t[i] + llabs(to - x[i]);           from = to;           to = x[i];         }         if (min(from, to) <= x[i] && max(from, to) >= x[i]) {           long long arrival = start + abs(from - x[i]);           if (t[i] <= arrival && (i == n - 1 ? true : (arrival <= t[i + 1]))) {             ans++;           }         }       }       cout << ans <<   n ;     }     return 0;   }