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