#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define ll long long

int main() {
	int t;
	cin>>t;
	while(t--){
		ll r,l;cin>>l>>r;
		ll n=sqrt(2*(r-l));
		while(n && n*(n+1)>2*(r-l)){n--;}
		cout<<n+1<<endl;
		
			
		
	}return 0;
}