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