#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; cin>>t;
    for(int asd = 0; asd < t; asd++){
        int n; cin>>n;
        ll pos = 0, goal = 1e9+1, time = 0, r = 0, lastgoal = 1e9+1, lastpos = 0;
        ll a, b;
        for(int i = 0; i < n; i++){
            cin>>a>>b;
            if(i > 0){
                if(goal > pos){
                    pos = min(goal, pos + (a-time));
                } else if(pos > goal){
                    pos = max(goal, pos - (a-time));
                }
            }
            time = a;
            if(pos == goal){
                goal = b;
            } 
            if((lastpos <= lastgoal && lastgoal <= pos) || (pos <= lastgoal && lastgoal <= lastpos)){
                r++;
            }
            if (i == 0)goal = b;
            lastpos = pos;
            lastgoal = b;
        }
        if((goal > pos && lastgoal >= pos && goal >= lastgoal) || (goal < pos && lastgoal <= pos && goal <= lastgoal) || lastgoal == pos)r++;
        cout<<r<<endl;
    }
    return 0;
}