Maximum Range

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Grammy has a simple connected undirected graph. Each of the edges has a value written on it. Please choose a simple cycle for her such that the values written on the cycle have the maximum possible range.

The range of a cycle is the difference between the maximum value and the minimum value written on it.

A cycle i_1e_1i_2e_2i_ke_ki_1i\_1 - e\_1 - i\_2 - e\_2 - \cdots - i\_k - e\_k - i\_1 (e_je\_j is some edge connecting vertices i_ji\_j and i_jmodk+1i\_{j\bmod k+1} in the graph) is simple if and only if each edge appears at most once in it.

To prove that you really found the cycle, you need to output the vertices on the cycle in order.

It is guaranteed that there is at least one cycle in the graph.

입력

The first line contains two integers nn and mm (3nm1053 \leq n \leq m \leq 10^5) denoting the number of vertices and the number of edges in the graph.

In each of the next mm lines, there are three integers uu, vv, ww (1u,vn1 \leq u, v \leq n, 109w109-10^9 \leq w \leq 10^9, uvu \neq v), indicating that there is an edge between vertex uu and vertex vv having value ww written on it. It is guaranteed that the graph is connected, and there is at most one edge between each pair of vertices.

출력

On the first line, output a single integer denoting the maximum range of a simple cycle in the graph.

On the second line, output a single integer kk denoting the number of edges in the cycle. It is not hard to find out that the number of edges is equal to the number of vertices in the cycle.

On the last line, output kk integers, denoting the vertices on the cycle in order. Note that these vertices can be repeated since only edges cannot be visited multiple times.

If there are multiple solutions, output any one of them.

힌트

In the first sample, the cycle 1-2-5-4-3-1 has the maximum range of 55, since the maximum value on the cycle is 33, and the minimum value on the cycle is 2-2, so the maximum range of a cycle is 3(2)=53-(-2)=5. It can be shown that there are no cycles with a range larger than 55.