def f(a,b,x): return 4*a*b < x**4 - 2*(x**2*(a+b)) + (a+b)**2 n = int(input()) for _ in range(n): a,b = map(int,input().split()) l = 0 r = 10**5 while r > l+1: m = (r+l)//2 if f(a,b,m): r = m else: l = m print(r)