N = int(input()) for i in range(N): a, b = map(int, input().split()) ok = 10 ** 12 ng = 2 subres = -2 * a * b + a * a + b * b while ng + 1 < ok: mid = (ok + ng) // 2 if mid ** 4 - 2 * a * mid ** 2 - 2 * b * mid ** 2 + subres > 0: ok = mid else: ng = mid print(ok)