#include using namespace std; #define ll long long #define pll pair #define pii pair #define fs first #define sc second #define ld long double const ld sq = sqrt(1e9+10)*2; const ld eps = 1e-8; void solve(){ ll a,b; cin>>a>>b; ld l = 0,r = sq; ld sa,sb; for(int i = 0;i<100;i++){ ld mid = (l+r)/2; if(mid*mid>=a)r = mid; else l = mid; } sa = l; l = 0,r = sq; for(int i = 0;i<100;i++){ ld mid = (l+r)/2; if(mid*mid>=b)r = mid; else l = mid; } sb = l; ld sum = ceil(sa+sb+eps); cout<<(ll)round(sum)<<'\n'; return; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--)solve(); }