import java.util.*;
public class PFSPath {
    static ArrayList<Node> graph = new ArrayList<>();
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in); // 標準入力から読む
	int n = sc.nextInt(); // ノードの数
	int m = sc.nextInt(); // エッジの数
	for (int i=0; i<n; i++)
	    graph.add(new Node(i, Integer.MAX_VALUE)); // 各ノードを生成する
	for (int i=0; i<m; i++) { // エッジの定義を読み込む
	    int s = sc.nextInt(); // 始点
	    int t = sc.nextInt(); // 終点
	    int w = sc.nextInt(); // 重み
	    graph.get(s).addEdge(t,w); // ノードsからtにエッジを張る
	    graph.get(t).addEdge(s,w); // ノードtからsにエッジを張る
	}
	Node src = graph.get(sc.nextInt());	// スタートノード
	Node dst = graph.get(sc.nextInt());	// 目的地ノード
	int d = dijkstra(src, dst);
	if (d ==Integer.MAX_VALUE) {
	    System.out.println("no route");
	} else {
	    System.out.println(d);
	    StringBuilder sb = new StringBuilder();
	    for (Node x: getRoute(src, dst)) sb.append(x.id + " ");
	    System.out.println(sb.toString());
	}
    }
    public static int dijkstra(Node src, Node dst) {
	HashSet<Node> fixed = new HashSet<>(); // 最短距離が確定したノード
	src.d = 0;	// 始点ノードの距離を0とおく
	var queue = new PriorityQueue<Node>();
	queue.add(src);
	while (queue.size() > 0) {
	    Node x = queue.poll(); // キューからの中で最小のノードを取り出す
	    assert !fixed.contains(x);
	    if (x == dst) return x.d; // 解を発見した
	    fixed.add(x); // x を確定ノードとする
	    for (Map.Entry<Integer,Integer> entry: x.edges.entrySet()) { // xから出ている各エッジに対して
		Node y = graph.get(entry.getKey()); // エッジの終端ノード
		int w = entry.getValue(); // エッジの重み
		int d2 = x.d + w; // xを経由したyまでの距離
		if (fixed.contains(y) || d2 >= y.d) continue;　// 「すでに確定済み」or「x経由は遠い」場合何もしない
		if (queue.contains(y)) queue.remove(y); // yがキューに含まれる場合は一旦取り出す
		y.d = d2; // yまでの距離を更新して
		y.via = x; // yの経由地はx
		queue.add(y);  // yをキューに追加する
	    }
	}
	return Integer.MAX_VALUE; // 到達不可能(非連結グラフ)
    }
    static ArrayList<Node> getRoute(Node src, Node dst) { // src->dst の最短経路
	ArrayList<Node> r = new ArrayList<>();
	r.add(dst); // dst から始めて
	Node x = dst;
	while (x != src) { //src まで逆順にたどる
	    x = x.via;
	    r.add(x);
	}
	Collections.reverse(r); // src->dst の順に並べ直す
	return r;
    }
    static class Node implements Comparable<Node> { // ノードの定義 (比較可能)
	int id;    // ノード番号
	int d;     // 距離
	Node via;  // 直前の経由ノード
	HashMap<Integer, Integer> edges; // エッジ: toノード, 重み
	public Node(int id, int d) {
	    this.id = id; 
	    this.d = d;
	    edges = new HashMap<>(); 
	}
	void addEdge(int t, int w) { edges.put(t, w); }
	public int compareTo(Node x) { return d - x.d; }
    }
}
