/*
* Tags: 
*/

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back


void solve() {
    int n; cin >> n;
    int ans = 0;
    vector<pair<int64_t, int64_t>> v; // ti , xi;
    forn (i, n) {
        int64_t t, x; cin >> t >> x;
        v.pb( {t, x});
    }
    v.pb({INT64_MAX, 0});
    int64_t nt = 0, dir = 1, x0 = 0, nx = 0;
    forn (i, n) {
        auto [t, x] = v[i];
        if (nt <= t) {
            x0 = nx;
            nx = x;
            nt = t + abs(x - x0);
            if (x > x0) dir = 1;
            else dir = -1;
            if (nt <= v[i + 1].first) ans++;
        } else {
            int64_t dt = (v[i + 1].first - t);
            x0 += (t - v[i - 1].first) * dir;
            // printf("%d\n", x0);
            if (dir > 0) {
                if (x >= x0 && x <= min(nx, x0 + dir * (dt))) ans++;
            } else {
                if (x <= x0 && x >= max(nx, x0 + dir * (dt))) ans++;
            }
        }
    }

    cout << ans << '\n';
}



int main(){
   ios_base::sync_with_stdio(0), cin.tie(0);
   int t = 1;
   cin >> t;
   for (; t; t--) solve();
}

/*
   * int overflow, array bounds
   * special cases (n=1?), set tle
   * do smth instead of nothing and stay organized
*/
