import math from decimal import * n = int(input()) for i in range(n): a,b = map(Decimal,input().split()) a = a.sqrt() b = b.sqrt() print(math.ceil(a+b) if math.ceil(a+b)!=a+b else math.ceil(a+b)+1)