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