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 * mid if X2 - C >= 0 and D * D > 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))