import java.util.*;
public class PFSPath {
    static ArrayList<Node> graph = new ArrayList<>();
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in); // read from Standard Input
	int n = sc.nextInt(); // nubmer of nodes
	int m = sc.nextInt(); // nubmer of edges
	for (int i=0; i<n; i++)
	    graph.add(new Node(i, Integer.MAX_VALUE)); // instanciate each node
	for (int i=0; i<m; i++) { // read edges
	    int s = sc.nextInt(); // one node of the edge
	    int t = sc.nextInt(); // another node of the edge
	    int w = sc.nextInt(); // weights
	    graph.get(s).addEdge(t,w); // add edge from s to t
	    graph.get(t).addEdge(s,w); // add edge from t to s
	}
	Node src = graph.get(sc.nextInt());	// start node
	Node dst = graph.get(sc.nextInt());	// destination node
	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<>(); // fixed node
	src.d = 0;	// distance of start node is 0
	var queue = new PriorityQueue<Node>();
	queue.add(src);
	while (queue.size() > 0) {
	    Node x = queue.poll(); // get minimum node from queue
	    assert !fixed.contains(x);
	    if (x == dst) return x.d; // find the answer
	    fixed.add(x); // set node x as fixed
	    for (Map.Entry<Integer,Integer> entry: x.edges.entrySet()) { // each edge from node x
		Node y = graph.get(entry.getKey()); // edge's endpoint
		int w = entry.getValue(); // edge's weights
		int d2 = x.d + w; // distance to y via x
		if (fixed.contains(y) || d2 >= y.d) continue;　// do nothing if fixed or further
		if (queue.contains(y)) queue.remove(y); // remove y from queue
		y.d = d2; // update distance to y
		y.via = x; // set the previous node of y is x
		queue.add(y);  // add y into queue
	    }
	}
	return Integer.MAX_VALUE; // unconnected
    }
    static ArrayList<Node> getRoute(Node src, Node dst) { // shortest path from src to dst
	ArrayList<Node> r = new ArrayList<>();
	r.add(dst); // start from dst
	Node x = dst;
	while (x != src) { // trace back to src
	    x = x.via;
	    r.add(x);
	}
	Collections.reverse(r); // reverse the list (src->dst)
	return r;
    }
    static class Node implements Comparable<Node> { // node
	int id;    // node identity
	int d;     // distance
	Node via;  // previous node
	HashMap<Integer, Integer> edges; // edge: (edge's endpoint, weights)
	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; }
    }
}
