#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
//#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif

struct order {
    long long int time;
    long long int position;
};

void solve(void){
    int n; std::cin >> n;
    std::vector<order> A(n); for(int i = 0; i < n; ++i) std::cin >> A[i].time >> A[i].position;
    int res = 0;{
        int index = 0; long long int pos = 0;
        while(index < n){
            if(A[index].position == pos){ ++res; ++index; continue; }
            else if(A[index].position > pos){
                // move postive
                const long long int until = A[index].time + (A[index].position - pos);
                int index2 = index;
                for(; index2 < n and A[index2].time < until; ++index2){
                    if(not (pos <= A[index2].position and A[index2].position <= A[index].position)) continue;
                    const long long int reach_time = A[index].time + A[index2].position - pos;
                    if(A[index2].position <= A[index].position and A[index2].time <= reach_time and (index2 + 1 >= n or reach_time <= A[index2 + 1].time)){
                        ++res;
                    }
                }
                pos = A[index].position;
                index = index2;
            }
            else{
                // move negative
                const long long int until = A[index].time + (pos - A[index].position);
                int index2 = index;
                for(; index2 < n and A[index2].time < until; ++index2){
                    if(not (A[index].position <= A[index2].position and A[index2].position <= pos)) continue;
                    const long long int reach_time = A[index].time + pos - A[index2].position;
                    if(A[index2].time <= reach_time and (index2 + 1 >= n or reach_time <= A[index2 + 1].time)){
                        ++res;
                    }
                }
                pos = A[index].position;
                index = index2;
            }
        }
    }
    std::cout << res << '\n';
}


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int Q; std::cin >> Q;
    while(Q--) solve();
    return 0;
}