def issatisfy(m, a, b) -> bool: s = m**2 - (a + b) if s <= 0: return False return 4*a*b < s**2 # INF = 1 << 60 INF = 10 ** 5 N = int(input()) for _ in range(N): A, B = map(int, input().split()) lo = 1 hi = INF ans = INF while lo <= hi: m = (lo + hi) // 2 if issatisfy(m, A, B): ans = min(ans, m) hi = m - 1 else: lo = m + 1 print(ans)