#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKCmludCBtYWluKCkgewoJaW50IHQ7CgljaW4+PnQ7Cgl3aGlsZSh0LS0pewoJCWxsIHIsbDtjaW4+Pmw+PnI7CgkJbGwgbj1zcXJ0KDIqKHItbCkpOwoJCXdoaWxlKG4gJiYgbioobisxKT4yKihyLWwpKXtuLS07fQoJCWNvdXQ8PG4rMTw8ZW5kbDsKCQkKCQkJCgkJCgl9cmV0dXJuIDA7Cn0=