#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ long long a, b; cin >> a >> b; long long ng = 0, ok = 1ll << 31, mid; while(ng + 1 < ok){ mid = (ng + ok) / 2; if(a * b <= mid * mid) ok = mid; else ng = mid; } if(a * b == ok * ok){ long long v = a + b + 2 * ok; ng = 0, ok = 1ll << 31; while(ng + 1 < ok){ mid = (ng + ok) / 2; if(v <= mid * mid) ok = mid; else ng = mid; } if(v == ok * ok) ok++; }else{ long double v = a + b + 2 * sqrt(a * b); ng = 0, ok = 1ll << 31; while(ng + 1 < ok){ mid = (ng + ok) / 2; if(v < mid * mid) ok = mid; else ng = mid; } } cout << ok << '\n'; } }