#include using namespace std; using ll = long long; using U = unsigned __int128; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; while (n--) { ll aa, bb; cin >> aa >> bb; U a = aa, b = bb; U l = 2, r = 1000000; auto ok = [&](U x) -> bool { U xx = x * x; if (xx <= a + b) return false; U t = xx - a - b; return t * t > 4 * a * b; }; while (r - l > 1) { U x = (l + r) / 2; if (ok(x)) r = x; else l = x; } cout << (ll)r << '\n'; } return 0; }