#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int, int>
#define pb push_back

#ifndef ONLINE_JUDGE
#define dbg(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);}
#else
#define dbg(...) 42
#endif
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(int i=0;i<v.size();++i) x<<v[i]<<" ";return x;} 
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;} 
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.first<<" "<<v.second;return x;} 
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }


void solve() {
    int n;
    cin >> n;
    int x[n], t[n + 1];
    t[n] = 2e18;
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i];
    }
    int pos = 0, t_last = 0;
    vector<vector<int>> ranges;
    for (int i = 0; i < n; i++) {
        // find l, r, tl, tr
        if (t_last <= t[i]) {
            ranges.pb({t[i], t[i] + abs(pos - x[i]), pos, x[i]});
            t_last = t[i] + abs(pos - x[i]);
            pos = x[i];
        } else {
            continue;
        }
    }
    int ans = 0;
    int j = 0;
    dbg(ranges);
    int M = ranges.size();
    vector<int> pos_t(n+1, 0);
    for (int i = 0; i < n; i++) {
        bool fd = 0;
        while (j < M) {
            if (t[i] >= ranges[j][0] and t[i] <= ranges[j][1]) { 
                break;
            }
            if (j < M - 1) {
                int t1 = ranges[j][1], t2 = ranges[j + 1][0];
                if (t[i] >= t1 and t[i] <= t2) {
                    pos_t[i] = ranges[j][3];
                    fd = 1;
                    break;
                } else if (t[i] > t2) {
                    j++;
                }
            } else {
                break;
            }
        }
        if (fd) {
            dbg(t[i], pos_t[i]);
            continue;
        }
        dbg(ranges[j][0]);
        pos_t[i] = (t[i] - ranges[j][0]);
        int dis = ranges[j][3] - ranges[j][2];
        if (dis < 0) {
            pos_t[i] = ranges[j][2] - pos_t[i];
        } else {
            pos_t[i] = ranges[j][2] + pos_t[i];
        }
        dbg(t[i], pos_t[i]);
    }
    // dbg("working");
    pos_t[n] = ranges.back()[3];
    for (int i = 0; i < n; i++) {
        int l = pos_t[i], r = pos_t[i + 1];
        if (l > r) {
            swap(l, r);
        }
        if (x[i] >= l and x[i] <= r) {
            dbg(i);
            ans++;
        }
    }
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

