import math n = int(input()) for i in range(n): A, B = map(int, input().split()) sum_sqrt = math.sqrt(A) + math.sqrt(B) X = math.ceil(sum_sqrt) print(X+1)