#include<bits/stdc++.h>
#define int long long
using namespace std;
int T;
int a,b;
vector<int>v;
inline void solve(){
cin>>a>>b;
int tmp = max(a,b);
int ans = lower_bound(v.begin(),v.end(),tmp) - v.begin() + 1;
if(ans*ans < a+b) ans++;
cout<<ans<<'\n';
}
signed main()
{
int now = 0;
int cnt = 1;
while(now <= 1e9){
if(now + cnt <= 1e9) v.push_back(now+cnt);
if(now + cnt*2 <= 1e9) v.push_back(now+cnt*2);
now += 2*cnt;
cnt += 2;
}
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--) solve();
return 0;
}
/*
1
2
5
8
13
18
25
*/