local mfl, mce = math.floor, math.ceil local q = io.read("*n") local function solve(x, a, b) local v = 1LL * x * x - a - b if v < 0LL then return false end if 2000000000LL < v then return true end return 4LL * a * b < v * v end for iq = 1, q do local a, b = io.read("*n", "*n") local l, r = 0, 1000000001 while 1 < r - l do local mid = mfl((l + r) / 2) if solve(mid, a, b) then r = mid else l = mid end end print(r) end