for _ in range(int(input())): a, b = map(int, input().split()) l, r = -1, 7000 while r - l > 1: x = (l + r) // 2 if 0 < x ** 4 - 2 * (a + b) * x ** 2 + (a + b) ** 2 - 4 * a * b: r = x else: l = x print(r)