for _ in range(int(input())): a, b = map(int, input().split()) ok = 70000 ng = 2 while ok - ng > 1: mid = (ok + ng) // 2 res = mid * mid - a - b if res * res > 4 * a * b and mid * mid > a + b: ok = mid else: ng = mid print(ok)