n = int(input()) for i in n: a, b = map(int, input().split()) l = 0 r = 1e7 while l < r : x = (l + r) // 2 d = x * x - a - b if 4 * a * b < d * d and x * x > a + b: r = x else: l = x + 1 print(l)