from sys import stdin n = int(input()) for _ in range(n): a, b = list(map(int, stdin.readline().split())) temp = a + b + int(2*(a*b)**0.5) temp = int(temp ** 0.5) print(temp+1)