N = int(input()) for _ in range(N): a, b = map(int, input().split()) lb = 0 ub = 10 ** 5 while ub - lb > 1: mid = (ub + lb) // 2 if 4 * a * b < (mid * mid - a - b) ** 2: ub = mid else: lb = mid print(ub)