n = int(input()) for i in range(n): a,b = map(int, input().split()) high = 100000 low = 0 while(high-low>1): mid = (high+low)//2 val = (mid*mid-a-b) v = val*val if v>4*a*b: high = mid else: low = mid print(high)