#include using namespace std; using ll = long long; using P = pair; using T = tuple; // #include // using namespace atcoder; // using mint = modint1000000007; #define rep(i, n) for(ll i = 0; i < n; i++) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << setprecision(10) << fixed; ll n; cin >> n; vector a(n), b(n); rep(i,n) cin >> a[i] >> b[i]; rep(i,n) { ll left = 1, right = 1e16; while( right-left > 1 ) { ll mid = (right+left)/2; bool f = ( (double)(sqrt(a[i])+sqrt(b[i])) < (double)mid); if( f ) right = mid; else left = mid; } cout << right << endl; } return 0; }