#include <bits/stdc++.h>

using namespace std;

bool success(int stime, int spos, int target, int x, int pt, int t, bool last) {
    // x = spos + m * t

    if (stime < 0) {
        return false;
    }

    int m = target - spos > 0 ? 1 : -1;

    if (m > 0 && target < x) {
        return false;
    }
    if (m < 0 && target > x) {
        return false;
    }
    int t0 = (x - spos) * m;

    if (t0 < 0) {
        return false;
    }

    if (t0 >abs( target - spos)) {
        t0 = target - spos;
    }

    long    long ta = (long long) t0 + (long long) stime;

    if (last) {
        return ta >= pt;
    }

    return ta >= pt && ta <= t;
}

int main() {
    int tests;
    cin >> tests;
    while (tests--) {

        int n;
        cin >> n;

        int res = 0;

        int stime, spos, target;
        target = 0;
        stime = -1;
        spos = 0;

        int pt, px, t, x;
        pt = -1;
        px = 0;

        for (int i = 0; i < n; i++) {
            cin >> t >> x;

            if (success(stime, spos, target, px, pt, t, false)) {

                // cout << "success " << pt <<"\n";
                res++;
            }

            if (t >= (long long) stime + abs(target - spos)) {
                stime = t;
                spos = target;
                target = x;
            }

            pt = t;
            px = x;
        }

        t = numeric_limits<int>::max();

        if (success(stime, spos, target, px, pt, t, true)) {
            res++;
        }

        cout << res << "\n";
    }
}
