def sqrt_by_newton(k, epsilon=0.00001): def f(x): return x - (x * x - k) / (2.0 * x) if k <= epsilon: return 0.0 x = k next_x = f(x) while abs(x - next_x) >= epsilon: x = next_x next_x = f(x) return next_x N = int(input()) for i in range(N): a, b = map(int, input().split()) m = sqrt_by_newton(a) n = sqrt_by_newton(b) print(int(m + n) + 1)