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