407881: GYM102916 E Powerless Mage

Memory Limit:512 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Powerless Magetime limit per test3 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

A mage knows n spells, the i-th of which requires qi blue mana, wi purple mana and ei orange mana (qi + wi + ei > 0). Let's say the mage has Q blue mana, W purple mana and E orange mana, and denote the total amount of mana Q + W + E as R. Knowing that the mage is unable to cast any spell, what can be the maximal value of R?

Input

The first line contains an integer n (1 ≤ n ≤ 200000) — the number of spells.

Each of the next n lines contains three integers qi, wi, ei (0 ≤ qi, wi, ei ≤ 109, qi + wi + ei > 0) — the manacosts of the i-th spell.

Output

Output the maximal total amount of mana R such that the mage is unable to cast any spell.

If this number is infinitely large (for any total amount of mana R, there could be a situation so that the mage is unable to cast any spell), output "Infinity".

ExamplesInput
4
0 0 100
0 100 0
100 0 0
61 71 81
Output
278
Input
6
0 0 100
0 100 0
100 0 0
0 11 61
11 61 0
61 0 11
Output
180
Input
3
3 1 1
1 3 1
1 1 3
Output
Infinity

加入题单

算法标签: