Under construction

Still being built. Things may change

Kaleidoscopic Route

Time limit2sMemory limit512 MB

Summary
Find a fewest-roads path from city 1 to city n that maximizes the gap between its largest and smallest road colorfulness.
Level

Medium7 of 10

Topics
Graph, BFS, Shortest path, Two pointers
Solved
No attempts yet

Problem

Kaleidostan has nn cities connected by mm bidirectional roads. The cities are numbered from 1 to nn. Each road has an integer called colorfulness.

Keanu wants to travel from city 1 to city nn. He wants a shortest route, meaning the route with the fewest roads. Among all shortest routes, he wants the kaleidoscopic one, meaning the route with the largest possible difference between the maximum and minimum colorfulness of its roads. Help Keanu find such a route.

Input

The first line contains two integers nn and mm, the number of cities and the number of roads (2≤n≤1052 \le n \le 10^5; 1≤m≤2⋅1051 \le m \le 2 \cdot 10^5).

The ii-th of the following mm lines contains three integers viv_i, uiu_i, and cic_i, the indices of the cities connected by the ii-th road and its colorfulness (1≤vi,ui≤n1 \le v_i, u_i \le n; vi≠uiv_i \neq u_i; 0≤ci≤1090 \le c_i \le 10^9).

Each pair of cities is connected by at most one road. It is guaranteed that you can travel from any city to any other city using the roads.

Output

In the first line, print a single integer kk, the number of roads in the required route.

In the second line, print k+1k+1 integers c0,c1,…,ckc_0, c_1, \ldots, c_k, the sequence of cities on the route (1≤ci≤n1 \le c_i \le n; c0=1c_0 = 1; ck=nc_k = n).

Hint

In the example test, the required route consists of 3 roads, and the difference between the maximum and minimum colorfulness of its roads is 8−2=68-2=6.

Examples1

  1. Example 1

    Input
    6 8
    1 5 2
    5 2 5
    3 5 4
    1 3 10
    3 4 6
    4 5 7
    4 6 8
    2 6 1
    
    Expected output
    3
    1 5 4 6