from decimal import Decimal import math n = int(input()) for _ in range(n): a, b = map(int, input().split()) print(math.ceil(Decimal(a)**Decimal('0.5') + Decimal(b)**Decimal('0.5') + Decimal('0.0000000000000001')))