One of the largest problems facing university students is procrastination (in fact, I'm procrastinating writing my thesis right now!).
Let's think about our life as a series of decisions. Each decision influences which life-paths you go down. At each point in your life, you will have many options to get you to other points. Those decisions may lead you on new adventures or back to places you've already been (e.g., final exams, which we will consider to be the same "point" in your first term as in the last year of studies). Each option comes with a "procrastination-factor". The higher the procrastination-factor, the more you are procrastinating. The total amount of procrastination done in your life-time is the sum of all procrastination-factors of the decisions you made along the way.
Given a series of life events and the possible decisions from each one, what is the most amount of procrastination you can accumulate over the remainder of your life-time?
First line of the input contains two integers N and M (1 ≤ N ≤ 100, 0 ≤ M ≤ N*(N-1) ), where N is the number of life-points and M is the number of decisions. Then follow M lines, each containing three integers A, B and F (1 ≤ A,B ≤ N, A ≠ B, |F| ≤ 1,000) denoting that when you are at life-point A, you can make the decision to go to life-point B with a procrastination factor of F. All decisions will be unique (i.e., there is at most one way to go directly from point A to point B). You are currently on life-point 1.
The output should consist of a single line containing the most amount of procrastination that you can possibly accumulate over your life-time. If there is no limit to the amount of procrastination you can do, output "Unlimited!".
2 2 1 2 10 2 1 20
3 3 1 2 10 2 3 20 3 1 -30