#include <bits/stdc++.h>

using namespace std;


int main()
{

    int t;
    cin >> t;

    while(t--)
    {
        unsigned int n;
        cin >> n;

        long long int t[n], x[n];
        long long int current_pos = 0;
        long long int current_time = 0;
        long long int prev_pos = 0;
        long long int prev_time = 0;

        for(int i=0; i<n; i++)
        {
            cin >> t[i] >> x[i];
        }

        unsigned int succ = 0;

        for(int i=0; i<n; i++)
        {
            if(t[i] >= current_time)
            {
                prev_time = t[i];
                current_time = abs(current_pos - x[i]) +  t[i];
                prev_pos = current_pos;
                current_pos = x[i];

                if(i < n-1)
                {
                    if(current_time >= t[i] && current_time <= t[i+1])
                    {
                        succ++;
                    }
                }
                else
                {
                    if(current_time >= t[i])
                    {
                        succ++;
                    }
                }
            }
            else
            {
                if(x[i] >= prev_pos && x[i] <= current_pos)
                {
                    long long int tmp = abs(x[i] - prev_pos) + prev_time;

                    if(i<n-1)
                    {
                        if(tmp >= t[i] && tmp <= t[i+1])
                        {
                            succ++;
                        }
                    }
                    else
                    {
                        if(tmp >= t[i])
                        {
                            succ++;
                        }
                    }
                }
                else if(x[i] <= prev_pos && current_pos <= x[i])
                {
                    long long int tmp = abs(x[i] - prev_pos) + prev_time;

                    if(i<n-1)
                    {
                        if(tmp >= t[i] && tmp <= t[i+1])
                        {
                            succ++;
                        }
                    }
                    else
                    {
                        if(tmp >= t[i])
                        {
                            succ++;
                        }
                    }
                }
            }
        }

        cout << succ << endl;
    }

    return 0;
}