n = int(input()) for i in range(n): a, b = list(map(int, input().split())) ng = int(1) ok = int(100000) while ok - ng > 1: c = (ok + ng) // 2 if c * c - a - b <= 0: ng = c continue if 4 * a * b < (c * c - a - b) * (c * c - a - b): ok = c else: ng = c print(ok)