#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=1e6+10;
#define INF 0x3f3f3f3f3f
int a[N];
int b[N];
const int M=1010;
void solve()
{
int n;
cin>>n;
for(int i=1;i<=n;++i)
cin>>a[i]>>b[i];
int p=0,q=0,ans=0;
for(int i=1;i<=n;i++)
{
int ti;
if(p==q)
q=b[i];
if(i==n||a[i+1]-a[i]>=abs(p-q))
ti=q;
else
if (p < q)
ti = p + a[i + 1] - a[i];
else
ti = p - a[i + 1] + a[i];
if((b[i]-ti)*(b[i]-p)<=0)
ans++;
p=ti;
}
cout<<ans<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
//t = 1;
cin>>t;
while (t--)
{
solve();
}
}
1719C - Fighting Tournament | 1642A - Hard Way |
285C - Building Permutation | 1719E - Fibonacci Strings |
1696C - Fishingprince Plays With Array | 1085A - Right-Left Cipher |
1508B - Almost Sorted | 1690C - Restoring the Duration of Tasks |
1055A - Metro | 1036D - Vasya and Arrays |
1139C - Edgy Trees | 37A - Towers |
353A - Domino | 409H - A + B Strikes Back |
1262A - Math Problem | 158C - Cd and pwd commands |
194A - Exams | 1673B - A Perfectly Balanced String |
1104B - Game with string | 1169B - Pairs |
1567D - Expression Evaluation Error | 78A - Haiku |
1287A - Angry Students | 1428A - Box is Pull |
234B - Reading | 581B - Luxurious Houses |
1481C - Fence Painting | 935A - Fafa and his Company |
22A - Second Order Statistics | 1720B - Interesting Sum |