/*
What if I could right my wrongs and save you from the pain
It's not enough, It's not enough for me to break 
the rule upon this world
I am never gonna leave you never wanna lose you
We'll make it in the end
Not backing down for real
I won't trace someone else's life
I know who I am
*/

// FUCK YOU COVID!


#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define Forn(i,a,b) for(int (i)=(a);(i) >= (b); --(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 



// Stolen Templates
template <typename T>
T MIN(T first) { return first; }

template <typename T, typename... Args>
T MIN(T first, Args... args) { return min(first, MIN(args...)); }


template <typename T>
T MAX(T first) { return first; }

template <typename T, typename... Args>

T MAX(T first, Args... args) { return max(first, MAX(args...)); }
// Stolen Templates end here




int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    ll T;
    cin>>T;

    while(T--)
    {
        ll ans = 0; ll ignore = 0; ll dir = 0;
        ll des = 0;

        ll n;
        cin>>n;

        vector <ll> t(n + 1);
        t[n] = INF;
        vector <ll> point;

        For(i,0,n) {
            ll x,y;
            cin>>x>>y;

            t[i] = x;
            point.pb(y);
        }

        ll where = 0; ll to = 0;

        //cout<<point[2]<<endl;

        For(i,0,n) {
            if (ignore <= t[i]) {
                ignore = t[i] + abs(point[i] - to); 
                des = point[i];
                if (point[i] >= to)
                    dir = 1;
                else
                    dir = -1;
                if (dir == 1) {
                    where = to;
                    to = min(to + t[i + 1] - t[i], des);
                } else {
                    where = to;
                    to = max(to - (t[i + 1] - t[i]), des);
                }

                if (min(where, to) <= point[i] and max(where, to) >= point[i])
                    ans += 1;
                //cout<<where<<' '<<to<<endl;
            } else {
                //cout<<where<<' '<<to<<' '<<i<<endl;
                
                if (dir == 1) {
                    where = to;
                    to = min(to + t[i + 1] - t[i], des);
                } else {
                    where = to;
                    to = max(to - (t[i + 1] - t[i]), des);
                }
                if (min(where, to) <= point[i] and max(where, to) >= point[i])
                    ans += 1;
            }
        }

        cout<<ans<<endl;

    }   

return 0;
}

// check all product based operations for integer overflow
// careful of renamed variables especially in loops
//python interactive_runner.py python local_testing_tool.py 0 -- c.exe





  


