#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define re return
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define all(n) n.begin(), n.end()
#define rall(n) n.rbegin(), n.rend()
#define fi first
#define se second
#define sz(n) int(n.size())
#define sqr(n) ((n) * (n))


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int, int> pii;


void GO() {
#ifdef LOL
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);

#endif
//    freopen("bridges.in", "r", stdin);
//    freopen("bridges.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

const ll INF = 1e18;
const ll mod = (1e9) + 7;
const int maxn = (int) 2e5 + 1;

///var
mt19937 rnd(time(0));
ll coor = 0, f = 0, go = 0, ans = 0;
vll t, x;
//
void shag(int i){
    if (t[i + 1] >= t[i] + abs(go - coor)) f = 0, coor = go;
    else{
        if (go > coor) coor += t[i + 1] - t[i];
        else coor -= t[i + 1] - t[i];
    }
}
void solve(){
    int n; cin >> n;
    ans = 0, coor = 0, f = 0, go = 0;
    t.assign(n, 0), x.assign(n, 0);
    rep(i, n) cin >> t[i] >> x[i];
    t.push_back(INF);
    rep(i, n){
        if (!f){
            ll d = abs(x[i] - coor);
            if (d <= t[i + 1] - t[i]) ans++, coor = x[i];
            else f = 1, go = x[i], shag(i);
        }
        else{
            ll l = coor;
            shag(i);
            ll r = coor;
            if (x[i] >= min(l, r) && x[i] <= max(l, r)) ans++;
        }
    }
    cout << ans << '\n';
}

///ПОБЕД РЕГИОНА
signed main() {
    GO();
    int Q = 1; cin >> Q;
    while (Q--) solve();
}
///ФИОЛ