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