import scipy N = int(input()) for i in range(N): a, b = map(int, input().split()) print(int(scipy.sqrt(a) + scipy.sqrt(b)) + 1)