from math import sqrt,ceil n=int(input()) eps=1e-10 for _ in range(n): a,b=map(int,input().split()) print(ceil(sqrt(a+b+2*sqrt(a*b))+eps))