#include <queue>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <stack>
#define int long long int
using namespace std;

int sign(int x) {
    if (x > 0) {
        return 1;
    }
    return -1;
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<pair<int, int>> v(n);
        for (auto& x : v) {
            cin >> x.first >> x.second;
        }
        v.push_back(make_pair(1e11, 0));
        int robotPos = 0;
        int lastTime = 0;
        int lastRemaining = 0;
        int numSuccessful = 0;
        for (int i = 0; i < n; i++) {
            auto &x = v[i];
            int timeElapsed = x.first - lastTime;
            if (timeElapsed < abs(lastRemaining)) {
                // your command failed lol
                robotPos += sign(lastRemaining) * timeElapsed;
                lastRemaining -= sign(lastRemaining) * timeElapsed;
                lastTime = x.first;
                int timeLeft = v[i + 1].first - x.first;
                int endpoint = min(timeLeft, abs(lastRemaining)) * sign(lastRemaining) + robotPos;
                if (min(endpoint, robotPos) <= x.second && x.second <= max(endpoint, robotPos)) {
                    numSuccessful++;
                }
            }
            else {
                robotPos += lastRemaining;
                lastRemaining = x.second-robotPos;
                lastTime = x.first;
                int timeLeft = v[i + 1].first - x.first;
                int endpoint = min(timeLeft, abs(lastRemaining)) * sign(lastRemaining) + robotPos;
                if (min(endpoint, robotPos) <= x.second && x.second <= max(endpoint, robotPos)) {
                    numSuccessful++;
                }
            }
        }
        cout << numSuccessful << endl;
    }
    return 0;
}