import math n = int(input()) for _ in range(n): a,b = map(float,input().split()) print((math.sqrt(a)+math.sqrt(b))//1+1)