Studies

No attempts yetTime limit1sMemory limit128 MB

Problem

The Computer Science program at Byteland University (BU) consists of nn 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 vv guarantees infinite income when the following holds: the student can start at level vv, submit a sequence of applications, and finally return to the starting level vv 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.

Input

The first line contains two integers nn and mm separated by a single space (2n3002 \le n \le 300, 1mn(n1)1 \le m \le n(n-1)): the number of levels and the number of applications to analyze.

Each of the following mm lines describes one application with three integers aia_i, bib_i, cic_i (1ai,bin1 \le a_i, b_i \le n, aibia_i \ne b_i, 109ci109-10^9 \le c_i \le 10^9). It means that submitting the application at level aia_i moves the student to level bib_i after the dean's decision, with an associated cost cic_i (a positive value is a gain, a negative value is a loss).

No ordered pair (ai,bi)(a_i, b_i) appears more than once, but (ai,bi)(a_i, b_i) and (bi,ai)(b_i, a_i) may both appear.

Output

On the first line print one integer kk, the number of starting levels that can yield infinite income. On the second line print those level numbers, each in the range 11 to nn, in increasing order separated by single spaces. If kk is 00, leave the second line empty.

Hint