Powerless Mage
시간 제한2초메모리 제한512 MB
n개의 주문 마나 비용 벡터가 주어질 때, 어떤 주문도 시전할 수 없는 최대 총 마나 Q+W+E를 구하거나 무한히 큰 경우를 판정한다.
문제
A mage knows spells, the -th of which requires blue mana, purple mana and orange mana (). Let's say the mage has blue mana, purple mana and orange mana, and denote the total amount of mana as . Knowing that the mage is unable to cast any spell, what can be the maximal value of ?
입력
The first line contains an integer () --- the number of spells.
Each of the next lines contains three integers , , () --- the manacosts of the -th spell.
출력
Output the maximal total amount of mana such that the mage is unable to cast any spell.
If this number is infinitely large (for any total amount of mana , there could be a situation so that the mage is unable to cast any spell), output "Infinity".