import decimal N = int(input()) AB = [list(input().split()) for _ in range(N)] r = decimal.Decimal('0.5') for a,b in AB: a,b = decimal.Decimal(a),decimal.Decimal(b) print(int(a**r+b**r)+1)