eolymp
bolt
Try our new interface for solving problems
Problems

Yen algorithm

Yen algorithm

Find the k-th shortest path between two fixed vertices in an undirected graph.

Input

First line contains number of vertices n (1n100) and edges m (1m4000) in the graph, and the number of the path k (1k500). Next lines describe the graph edges - triple (u, v, w) describes the edge connecting the vertices u and v of weight w. The last line contains numbers of two vertices s and t, between which the path must be found.

There can be no multiple edges in a graph; there can be no loops. All weights are positive and do not exceed 10000. It is guaranteed that the k-th path exists.

Output

In the first line print two numbers - the desired weight of the path and the number of vertices in it. In the next line print the path itself - a sequence of vertex numbers.

Time limit 1 second
Memory limit 128 MiB
Input example #1
5 10 3
1 2 6
1 3 13
1 4 18
1 5 35
2 3 14
2 4 34
2 5 17
3 4 22
3 5 15
4 5 34
1 5
Output example #1
35 2
1 5