from math import isqrt for _ in range(int(input())): A, B = map(int, input().split()) print(isqrt(A + B + 2 * isqrt(A * B) + 1) + 1)