from decimal import Decimal n = int(input()) for i in range(n): a,b = map(Decimal,input().split()) a **= Decimal("0.5") b **= Decimal("0.5") print(int(a + b) + 1)