#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; assert(1 <= n && n <= 200000); while(n--){ unsigned long long a, b; cin >> a >> b; assert(1 <= a && a <= 1000000000); assert(1 <= b && b <= 1000000000); unsigned long long ok = 65000, ng = 0; while(ok - ng > 1){ unsigned long long mid = (ok + ng) / 2; unsigned long long s, mid2 = mid * mid; s = mid2 - a - b; if(mid2 >= a + b){ if(4ULL * a * b < s * s){ ok = mid; }else{ ng = mid; } }else{ ng = mid; } } cout << ok << endl; } }