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