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