n = int(input()) for _ in range(n): a, b = map(float, input().split()) print(int((a**0.5 + b**0.5) // 1 + 1))