import sys input=sys.stdin.readline n = int(input()) for i in range(n): a, b = map(int, input().split()) c = a + b d = (a - b) ** 2 hi = 10 ** 5 lw = 0 while hi - lw > 1: mid = (hi + lw) // 2 if mid ** 4 - 2 * mid ** 2 * c + d > 0: hi = mid else: lw = mid print(hi)