def solve(): a, b = map(int, input().split()) def ok(x): if x**2 - a - b < 0: return False return 4 * a * b < (x**2 - a - b) ** 2 l = 0 r = 10**5 while r - l > 1: mid = (l + r) // 2 if ok(mid): r = mid else: l = mid print(r) for _ in range(int(input())): solve()