for _ in range(int(input())): a, b = map(int, input().split()) ok, ng = 10**5, 0 while ok - ng != 1: vs = (ok + ng) >> 1 jud = vs * vs - a - b if jud < 0: ng = vs continue if 4 * a * b < jud * jud: ok = vs else: ng = vs print(ok)