N = int(input()) for i in range(N): A, B = map(int, input().split()) ng = 0 ok = 100000 while ok - ng > 1: mid = (ok + ng) // 2 if 4 * A * B < (mid * mid - A - B) * (mid * mid - A - B) and mid * mid - A - B > 0: ok = mid else: ng = mid print(ok)