You are given a weighted undirected graph with vertices and edges. The edges are numbered from to , and edge connects vertices and () with weight . There is at most one edge between any pair of vertices.
A path is a sequence of distinct vertices such that there exists an edge between and for all . The length of a path is the sum of the weights of all edges along the path (equal to if the path consists of a single vertex).
It is guaranteed that there exists at least one path between any two vertices of the graph. The distance between two vertices and , denoted , is defined as the length of the shortest path connecting them.
An honest path is a path such that for all .
Your task is to find the longest honest path that ends at vertex .
Input data
The first line contains two integers and – the number of vertices and the number of edges, respectively.
Each of the next lines contains three integers , and , describing edge .
Output data
Output two lines:
- The first line should contain two integers and – the total length of the longest honest path ending at vertex , and the number of vertices in that path.
- The second line should contain integers, representing the vertices of one such path in order.
If multiple solutions exist, you may output any of them.
Constraints and clarifications
- .
- .
- for each .
- for each .
- The graph is a connected simple graph.
| # | Score | Constraints |
|---|---|---|
| 1 | 0 | Examples. |
| 2 | 5 | . |
| 3 | 20 | . |
| 4 | 10 | The graph is a tree, i.e., . |
| 5 | 15 | for each . |
| 6 | 50 | No additional constraints. |
In this task you can get partial scores in every subtask. You will receive of the points for a subtask if you correctly determine the maximum length, but do not output the path itself.
If you wish to output only the length of the longest honest path, you should output on the first line, and omit the second line.
Example 1
stdin
4 4
1 2 1
2 3 1
3 4 1
1 4 2
stdout
2 3
2 3 4
Explanation
In the first sample case an honest path ending in node is . We have ,
, . Another honest path of maximum length is .
Note that, since , the path is not honest.
Example 2
stdin
4 4
1 2 10
2 3 1
3 4 1
1 4 3
stdout
12 4
1 2 3 4