#include using namespace std; using ll = unsigned long long; using ld = long double; bool hitoshii(ll s,ld sahen){ if(abs((ld)s-(ld)sahen)<=0.0001)return true; return false; } bool hantei(ll A,ll B,ll X){ ld a = sqrt(A);ld b = sqrt(B); if((ld)X-a-b<=0.0001)return false; return true; } int main(){ ll N;cin >> N; while(N--){ ll A,B;cin >> A >> B; ld sahen = sqrt(A)+sqrt(B); ll s = sahen; if(hantei(A,B,s))cout << s << endl; else cout << s+1 << endl; } }