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