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 ** 2 - A - B) ** 2: ok = mid else: ng = mid print(ok)