#include using namespace std; #define overload4(_1, _2, _3, _4, name, ...) name #define rep1(n) for(int i = 0; i < (int)(n); ++i) #define rep2(i, n) for(int i = 0; i < (int)(n); ++i) #define rep3(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep4(i, a, b, c) for(int i = (a); i < (int)(b); i += (c)) #define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__) using ll = long long; using ull = unsigned long long; using ld = long double; using u16 = uint16_t; int main(){ int N; cin >> N; auto isok = [](ull x, ull a, ull b){ if(x*x - a - b < 0)return false; return 4*a*b < (x*x - a - b) * (x*x - a - b); }; rep(i,N){ ull a,b; cin >> a >> b; ull ok = 1e10; ull ng = 1; while(ok - ng > 1){ ull mid = (ok + ng)/2ull; if(isok(mid, a, b))ok = mid; else ng = mid; } cout << ok << endl; } }