from math import sqrt N = int(input()) A_B = list() answer = "" for i in range(N): A, B = map(int, input().split()) answer += str(int(sqrt(A) + sqrt(B) + 1)) if i+1 != N: answer += "\n" print(answer)