#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
vector<long long> tim(N), pos(N), cur(N);

int main() {
    long long T, n, act, start, des, dir, ans, startTime;
    cin>>T;
    for(long long t = 1; t <= T; ++t) {
        tim[0] = pos[0] = start = des = act = ans = startTime = 0;
        cin>>n;
        for(long long i = 1; i <= n; ++i) {
            cin>>tim[i]>>pos[i];
            if(tim[i] >= act) {
                cur[i] = des;
                startTime = tim[i];
                act = tim[i] + abs(des - pos[i]);
                start = des;
                des = pos[i];
            } else {
                dir = (start <= des) ? 1 : -1;
                cur[i] = start + dir * (tim[i] - startTime);
            }
        }
        cur[n+1] = des;
        for(long long i = 1; i <= n; ++i) {
            if(min(cur[i],cur[i+1]) <= pos[i] && pos[i] <= max(cur[i],cur[i+1])) {
                ans += 1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}