#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <array>


#define ll long long int
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define fo(n) for(ll j=0; j<n; j++)
#define fo1(a, n) for(ll j=a; j<n; j++)
#define fov(j,a,n) for(ll j=a; j<n; j++)
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define minv(v) min_element(v.begin(), v.end())
#define maxv(v) max_element(v.begin(), v.end())
#define ubv(v,n) upper_bound(v.begin(), v.end(), n)
#define lbv(v,n) lower_bound(v.begin(), v.end(), n)
#define mll map<ll,ll>
#define mod 1000000007
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define mp make_pair

using namespace std;


void printV(vll& v) {
    for (auto x : v) { cout << x << " "; }
    cout << endl;
}
void printVV(vvll& vv) {
    for (auto x : vv) {
        for (auto y : x) { cout << y << " "; }
        cout << endl;
    }
}
void printVS(vector<string> v) {
    for (auto x : v) { cout << x << endl; }
}


int gcd(int a, int b) {
    int R;
    while ((a % b) > 0) {
        R = a % b;
        a = b;
        b = R;
    }
    return b;
}




int solve() {
    ll n; cin >> n;
    vll t(n), x(n);
    fo(n) cin >> t[j] >> x[j];

    ll ans = 0;
    ll pos = 0;
    ll prevpos = 0;
    ll des = 0;
    ll xi = x[0];
 
    des = x[0];
    
    fo1(1, n) {
        bool right = ((des - pos) > 0);
        prevpos = pos;
        if (right) { pos = min(des, prevpos + t[j] - t[j - 1]); }
        else if (!right) { pos = max(des, prevpos - t[j] + t[j - 1]); }
        right = ((pos - prevpos) > 0);
        if (right && xi <= pos && xi >= prevpos) { 
            ans++; 
        }
        else if (!right && xi >= pos && xi <= prevpos) { 
            ans++; 
        }
        xi = x[j];
        if (des == pos) des = x[j];
    }

    

    prevpos = pos;
    pos = des;
    bool right = ((pos - prevpos) > 0);
    if (right && xi <= pos && xi >= prevpos) {
        ans++;
    }
    else if (!right && xi >= pos && xi <= prevpos) {
        ans++;
    }

    cout << ans << endl; return 0;
}





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