#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 = [](__uint128_t x, __uint128_t a, __uint128_t b){ if((x*x - a - b) < 0)return false; else return 4*a*b < ((x*x - a - b) * (x*x - a - b)); }; rep(i,N){ ll a,b; cin >> a >> b; ll ok = 1000'000'00ll; ll ng = 1; while(abs(ok - ng) > 1ll){ ll mid = (ok + ng)/2ll; if(isok(mid, a, b))ok = mid; else ng = mid; } cout << ok << endl; } }