import java.util.*;
public class DijkstraPath {
    static int[] via; // 経由ノード
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); // 標準入力から読む
        int n = sc.nextInt(); // ノードの数
        int m = sc.nextInt(); // エッジの数
        int[][] mat = new int[n][n]; // ノードの接続関係を表す隣接行列
        for (int i=0; i<n; i++) // 隣接行列を初期化する
            for (int j=0; j<n; j++)
                mat[i][j] = (i==j) ? 0 : -1;
        for (int i=0; i<m; i++) { // エッジの定義を読み込む
            int s = sc.nextInt(); // 始点
            int t = sc.nextInt(); // 終点
            int w = sc.nextInt(); // 重み
            mat[s][t] = mat[t][s] = w;
        }
        int src = sc.nextInt(); // スタートノード
        int dst = sc.nextInt(); // 目的地ノード
        int d = dijkstra(mat,src,dst);
        if (d == Integer.MAX_VALUE) {
            System.out.println("no route");
        } else {
            System.out.println(d);
            StringBuilder sb = new StringBuilder();
            for (int x: getRoute(src, dst)) sb.append(x + " ");
            System.out.println(sb.toString());
        }
    }
    static ArrayList<Integer> getRoute(int src, int dst) {
        ArrayList<Integer> r = new ArrayList<>();
        r.add(dst);
        int x = dst;
        while (x != src) {
            x = via[x];
            r.add(x);
        }
        Collections.reverse(r);
        return r;
    }
    public static int dijkstra(int[][] mat,int src,int dst) {
        int n = mat.length;
        int[] distance = new int[n]; // 各ノードへの最短距離
        boolean[] fixed = new boolean[n]; // 各ノードの最短距離が確定したか?
        via = new int[n];  // 経由ノード
        for (int i=0; i<n; i++) { // ノードを初期化する
            distance[i] = Integer.MAX_VALUE; // 距離は無限大
            fixed[i] = false;   // 最短距離は未確定
            via[i] = -1; // 経由ノードは未確定
        }
        distance[src] = 0;      // 始点ノードの距離は0
        while (true) {
            int x = minIndex(distance,fixed); // 未確定の中で最小のノード
            if (x == dst) return distance[x]; // 解を発見した
            if (x < 0 || distance[x]==Integer.MAX_VALUE) return Integer.MAX_VALUE; // 非連結グラフ
            fixed[x] = true; // ノード x までの距離は確定となる
            for (int y=0; y<n; y++) { // 各ノードに関して
                if (mat[x][y]>0 && !fixed[y]) { // xからyへエッジが存在し、yが未確定ならば
                    int d2 = distance[x]+mat[x][y];// ｘを経由したyまでの距離
                    // 今までの距離よりも小さければ、それを覚える
                    if (d2 < distance[y]) { distance[y] = d2; via[y] = x; }
                }
            }
        }
    }
    // fixed[]がfalseの中で、distance[]が最小のインデックスを返す
    static int minIndex(int[] distance,boolean[] fixed) {
        int idx = -1;
        for (int i=0; i<fixed.length; i++) {
            if (!fixed[i]) // 未確定で
                if (idx < 0 || distance[idx] > distance[i]) idx = i; // 最小距離のインデックス
        }
        return idx;
    }
}
