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