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