def solve(): a, b = map(int, input().split()) def ok(x): return (x**2 + b - a) ** 2 > 4 * x**2 * b 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()