The Computer Science program at Byteland University (BU) consists of n levels. Each level corresponds to a semester, but the number of levels can be larger or smaller than the number of semesters in a classical CS program.
During the studies a student may submit various kinds of applications to the dean. A single application moves the student from the current level to another level and, at the same time, affects the student's budget. The effect can be a gain (a scholarship, a positive amount) or a loss (charges for extra classes, a negative amount).
Byteman is a lazy but very clever BU student. He does not care about graduating quickly; the only thing he cares about is maximizing his income. The dean behaves deterministically, meaning the outcome of a given application (the level it leads to and the associated cost) is always the same. Byteman may submit the same application as many times as he likes.
A level v guarantees infinite income when the following holds: the student can start at level v, submit a sequence of applications, and finally return to the starting level v while the total of the costs earned along the way is positive. Repeating such a closed process lets him grow his income without bound.
Given the description of all possible applications, write a program that finds every starting level that can lead to infinite income.
The first line contains two integers n and m separated by a single space (2≤n≤300, 1≤m≤n(n−1)): the number of levels and the number of applications to analyze.
Each of the following m lines describes one application with three integers ai, bi, ci (1≤ai,bi≤n, ai=bi, −109≤ci≤109). It means that submitting the application at level ai moves the student to level bi after the dean's decision, with an associated cost ci (a positive value is a gain, a negative value is a loss).
No ordered pair (ai,bi) appears more than once, but (ai,bi) and (bi,ai) may both appear.
On the first line print one integer k, the number of starting levels that can yield infinite income. On the second line print those level numbers, each in the range 1 to n, in increasing order separated by single spaces. If k is 0, leave the second line empty.
