def isqrt(n):
    if n == 0: return 0
    x = 1 << (n.bit_length() + 1) // 2
    y = (x + n // x) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
for a, b in AB:
    x = isqrt(a+b+isqrt(4*a*b))
    print(x+1)