#include using namespace std; using ll = long long; template T MUL(T a, T b){ T res; return __builtin_mul_overflow(a, b, &res)? std::numeric_limits::max() : res; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ ll a, b; cin >> a >> b; ll ng = 0, ok = 1 << 16, mid; while(ng + 1 < ok){ mid = (ng + ok) / 2; ll r = max(0ll, mid * mid - a - b); if(4 * a * b < MUL(r, r)) ok = mid; else ng = mid; } cout << ok << '\n'; } }