from sys import stdin input = stdin.readline def solve(A, B): C = A + B D = A - B left = 0 right = 63245 while right - left > 1: mid = (left + right) // 2 X2 = mid ** 2 if D ** 2 > X2 * (2 * C - X2): right = mid else: left = mid return right N = int(input()) for _ in range(N): A, B = [int(x) for x in input().split()] print(solve(A, B))