N = int(input()) for i in range(N): a, b = map(int, input().split()) ok = 10 ** 18 ng = 0 subres = -2 * a * b + a * a + b * b while ng + 1 < ok: mid = (ok + ng) // 2 mid_squared = mid * mid mid_fourth = mid_squared * mid_squared # 不要な累乗計算を事前に行うことで計算の繰り返しを減らす if mid_fourth - 2 * (a + b) * mid_squared + subres > 0: ok = mid else: ng = mid print(ok)