Rings of Saturn

No attempts yetTime limit2sMemory limit256 MB

Problem

Reports have come in that Enceladians, from Saturn's moon Enceladus, have infiltrated Earth's population and pass as humans.

No individual has been named yet. From intercepted communications the Android Communications Ministry has established two facts. The Enceladians are spread across major cities, and they work in rings of exactly seven people. Every person suspected of being an Enceladian carries an identifier. No communication crosses from one ring to another.

Each intercepted communication carries a threat level. Examine the associations implied by the communications and find every ring of exactly seven people. The threat level of a ring is the sum of the threat levels of all communications carried out inside that ring.

Two people belong to the same ring when a communication connects them directly, or when a chain of communications connects them through other people. A person who appears in no communication forms a ring alone. The same pair of people can appear in several communications, and every recorded line adds its own threat level.

Input

The input contains a single test case.

The first line holds the number of people nn (0<n2000000 < n \le 200000) and the number of communication lines mm (1m1000001 \le m \le 100000) to process.

Each of the next mm lines holds three integers separated by a single space: the sender's identifier idsid_s, the receiver's identifier idrid_r (0ids,idr<n0 \le id_s, id_r < n, idsidrid_s \ne id_r), and the threat level tt (0<t100 < t \le 10) of that communication.

Output

Print information on every ring of exactly seven people with proven communication between each other.

Use one line per ring. Print the identifier of the person with the lowest identifier in that ring, a single space, then the total threat level of the ring.

Print the rings in descending order of total threat level. Rings with the same total go in ascending order of the identifier printed at the start of the line.

If no ring of exactly seven people is found, print this single line.

There is currently no threat to Earth