Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
G. Run for beer

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputPeople in BubbleLand like to drink beer. Little do you know, beer here is so good and strong that every time you drink it your speed goes 10 times slower than before you drank it.

Birko lives in city Beergrade, but wants to go to city Beerburg. You are given a road map of BubbleLand and you need to find the fastest way for him. When he starts his journey in Beergrade his speed is 1. When he comes to a new city he always tries a glass of local beer, which divides his speed by 10.

The question here is what the minimal time for him to reach Beerburg is. If there are several paths with the same minimal time, pick the one that has least roads on it. If there is still more than one path, pick any.

It is guaranteed that there will be at least one path from Beergrade to Beerburg.

Input

The first line of input contains integer *N* — the number of cities in Bubbleland and integer *M* — the number of roads in this country. Cities are enumerated from 0 to *N* - 1, with city 0 being Beergrade, and city *N* - 1 being Beerburg. Each of the following *M* lines contains three integers *a*, *b* (*a* ≠ *b*) and *len*. These numbers indicate that there is a bidirectional road between cities *a* and *b* with length *len*.

- 2 ≤
*N*≤ 10^{5} - 1 ≤
*M*≤ 10^{5} - 0 ≤
*len*≤ 9 - There is at most one road between two cities

Output

The first line of output should contain minimal time needed to go from Beergrade to Beerburg.

The second line of the output should contain the number of cities on the path from Beergrade to Beerburg that takes minimal time.

The third line of output should contain the numbers of cities on this path in the order they are visited, separated by spaces.

Examples

Input

8 10

0 1 1

1 2 5

2 7 6

0 3 2

3 7 3

0 4 0

4 5 0

5 7 2

0 6 0

6 7 7

Output

32

3

0 3 7

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/13/2021 13:33:37 (i1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|