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