from decimal import * getcontext().prec = 20 n=int(input()) eps=Decimal('0.00000000000000000001') for _ in range(n): a,b=map(Decimal,input().split()) print((a.sqrt()+b.sqrt()+eps).__ceil__())