시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB269807135.149%

문제

After last year’s edition of the BAPC, you are still stuck in Delft. In order to participate again this year, you are going to Amsterdam by bus. During the journey you look out of the window and look for traffic signs that point in the direction of Amsterdam. To your surprise, you notice that the bus is never taking the roads that are pointed out by the signs!

You think that the bus company might have chosen a route such that, at no intersection, the bus goes in the direction that is pointed to by the signs. Your friends, however, find this very unbelievable, and don’t think this is possible. Can you figure out whether there exists a bus route that satisfies this requirement? Note that a bus route never visits the same place twice.

A traffic sign pointing in the direction of the shortest route to Amsterdam is placed at every intersection. You may assume that the input graph is both simple and connected, and that there is a unique optimal route to Amsterdam from every intersection.

입력

  • A single line containing two integers: n (2 ≤ n ≤ 105), the number of intersections, and m (1 ≤ m ≤ 106), the number of undirected roads that connect the intersections. The intersections are numbered from 0 to n − 1. Delft is denoted by intersection i = 0 and Amsterdam is denoted by intersection i = 1.
  • m lines that specify the roads
    • A road is specified by three integers, ai, bi (0 ≤ ai, bi < n and ai ≠ bi) and di (0 ≤ di ≤ 500000), where ai and bi are ids of the two intersections that are connected by this road and di is the distance that the bus has to travel to get from ai to bi or vice versa.

출력

As output, give one of the following:

  • A path from Delft to Amsterdam that satisfies the requirements, in case such a path exists.
    • A path is specified by a single line containing an integer k, the length of the path, followed by k integers pi that specify the intersections along the path in the order in which they are crossed, with p0 = 0 and pk−1 = 1.
  • The text “impossible”, if such a path does not exist.

예제 입력 1

4 5
0 2 5
2 1 5
0 3 10
3 1 20
3 2 5

예제 출력 1

3 0 3 1

예제 입력 2

4 3
0 1 10
1 2 20
2 3 30

예제 출력 2

impossible

예제 입력 3

7 9
0 1 800
6 2 300
2 3 75
3 4 80
4 5 50
4 1 100
1 6 35
0 2 120
0 3 100

예제 출력 3

2 0 1