시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB96562.500%

문제

There has been reported an infiltration of our Earth’s population by Enceladians, from Saturn’s moon Enceladus, posing as humans.

While the names of specific individuals have not been identified we, the Android Communications Ministry, do know from intercepted communications that the Enceladians are strategically located in major cities and that they work together in rings of exactly seven individuals. Each individual suspected of being an Enceladian has been given an identifier. Each ring is isolated from the other rings in terms of communication.

Each communication assessed by the Ministry has a threat level assigned to it. Your task is to examine the associations implied by the communications and to locate any rings of exactly seven individuals for further investigation. The threat level of a ring of individuals is calculated by summing the threat levels of all communications carried out by the ring.

입력

The input contains a single test case.

The first line of input will specify the number of individuals n (0 < n ≤ 200 000) and the number of communications lines m (1 ≤ m ≤ 100 000) to be processed.

The next m lines each contain three integers separated by a single space, ids, idr (0 ≤ ids, idr < n; ids ≠ idr) and t (0 < t ≤ 10), being the sender’s identifier, the receiver’s identifier and the threat level of the communication respectively.

출력

Output consists of information on all rings of exactly seven individuals who have proven communication between each other.

The information for each ring must be on a separate line and be composed of the id of the individual with the lowest identifier who was involved in the ring, followed by a single space then the total threat level of the ring.

Rings should be output in descending order of the total threat level for the ring. If any rings have the same threat level, rings should then be output in ascending order of the identifier used for the ring.

If no rings of exactly seven individuals are discovered, the output should be:

There is currently no threat to Earth

예제 입력 1

20 18
8 0 3
0 1 4
18 14 10
15 10 7
15 9 5
13 6 3
17 19 6
10 3 1
3 7 5
5 17 1
4 11 8
7 13 7
3 10 9
5 11 7
15 7 2
15 3 1
8 16 2
19 14 7

예제 출력 1

3 40
4 39

예제 입력 2

2 1
0 1 10

예제 출력 2

There is currently no threat to Earth