#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int INF = 2e9 + 239;

void solve() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> t(n);
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i];
    }
    int st_pos = 0;
    int st_time = 0;
    int dir = 0;
    int go_time = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (t[i] < st_time + go_time) {
            int L = t[i] - st_time;
            int R = go_time;
            if (i + 1 < n) R = min(R, t[i + 1] - st_time);
            int lx = st_pos + dir * L;
            int rx = st_pos + dir * R;
            if (lx > rx) swap(lx, rx);
            ans += (lx <= x[i] & x[i] <= rx);
        } else {
            st_pos = st_pos + dir * go_time;
            st_time = t[i];
            go_time = x[i] - st_pos;
            if (go_time < 0) {
                dir = -1;
                go_time *= -1;
            } else {
                dir = 1;
            }
            int L = 0;
            int R = INF;
            if (i + 1 < n) R = t[i + 1] - t[i];
            int lx = st_pos + dir * L;
            int rx = st_pos + dir * R;
            if (lx > rx) swap(lx, rx);
            ans += (lx <= x[i] & x[i] <= rx);
        }
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int q;
    cin >> q;
    while (q--) {
        solve();
    }
}
