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