Problem: Little girl Susie accidentally found her elder brother's notebook. She has many things to do, more important than solving problems, but she found this problem too interesting, so she wanted to know its solution and decided to ask you about it. So, the problem statement is as follows.

Let's assume that we are given a connected weighted undirected graph G = (V, E) (here V is the set of vertices, E is the set of edges). The shortest-path tree from vertex u is such graph G1 = (V, E1) that is a tree with the set of edges E1 that is the subset of the set of edges of the initial graph E, and the lengths of the shortest paths from u to any vertex to G and to G1 are the same. 

You are given a connected weighted undirected graph G and vertex u. Your task is to find the shortest-path tree of the given graph from vertex u, the total weight of whose edges is minimum possible.

Input

The first line contains two numbers, n and m (1 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) — the number of vertices and edges of the graph, respectively.

Next m lines contain three integers each, representing an edge — ui, vi, wi — the numbers of vertices connected by an edge and the weight of the edge (ui ≠ vi, 1 ≤ wi ≤ 109). It is guaranteed that graph is connected and that there is no more than one edge between any pair of vertices.

The last line of the input contains integer u (1 ≤ u ≤ n) — the number of the start vertex.

Output

In the first line print the minimum total weight of the edges of the tree.

In the next line print the indices of the edges that are included in the tree, separated by spaces. The edges are numbered starting from 1 in the order they follow in the input. You may print the numbers of the edges in any order.

If there are multiple answers, print any of them.

Examples

Input

3 3
1 2 1
2 3 1
1 3 2
3


Output

2
1 2 


Input

4 4
1 2 1
2 3 1
3 4 1
4 1 2
4


Output

4
2 3 4 

Note

In the first sample there are two possible shortest path trees:

  * with edges 1 – 3 and 2 – 3 (the total weight is 3); 
  * with edges 1 – 2 and 2 – 3 (the total weight is 2); 



And, for example, a tree with edges 1 – 2 and 1 – 3 won't be a shortest path tree for vertex 3, because the distance from vertex 3 to vertex 2 in this tree equals 3, and in the original graph it is 1.

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class CODEFORCES {
	private InputStream is;
	private PrintWriter out;

	class Pair implements Comparable<Pair> {
		long u;
		long v;

		public Pair(long u, long v) {
			this.u = u;
			this.v = v;
		}

		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}

		public int compareTo(Pair other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u) : Long.compare(v, other.v);
		}

		public String toString() {
			return u + " " + v;
		}
	}

	class Pairs implements Comparable<Pairs> {
		long u;
		long v;
		int id;
		int p, pa;

		public Pairs(long u, long v, int w, int z, int x) {
			this.u = u;
			this.v = v;
			this.id = w;
			this.p = z;
			pa = x;
		}

		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) {
			Pairs other = (Pairs) o;
			return u == other.u && v == other.v && id == other.id && p == other.p;
		}

		public int compareTo(Pairs other) {
			return Long.compare(u, other.u) != 0 ? Long.compare(u, other.u)
					: Long.compare(v, other.v) != 0 ? Long.compare(v, other.v) : Long.compare(id, other.id);
		}

		public String toString() {
			return u + " " + v + " " + id + " " + p;
		}
	}

	int[] arr, size;

	void initialize(int n) {
		arr = new int[n];
		size = new int[n];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = i;
			size[i] = 1;
		}
	}

	int root(int n) {
		while (n != arr[n])
			n = arr[n];
		return n;
	}

	boolean find(int p, int q) {
		if (root(p) == root(q))
			return true;
		return false;
	}

	void union(int p, int q) {
		int rp = root(p);
		int rq = root(q);
		if (rp == rq)
			return;
		if (size[rp] > size[rq]) {
			arr[rq] = rp;
			size[rp] += size[rq];
		} else {
			arr[rp] = rq;
			size[rq] += size[rp];
		}
	}

	void solve() {
		int n = ni(), m = ni();
		ArrayList<Pair> a[] = new ArrayList[n];
		ArrayList<Integer> b[] = new ArrayList[n];
		initialize(n);
		for (int i = 0; i < n; i++) {
			a[i] = new ArrayList<Pair>();
			b[i] = new ArrayList<Integer>();
		}
		for (int i = 0; i < m; i++) {
			int u = ni() - 1, v = ni() - 1, w = ni();
			a[u].add(new Pair(v, i));
			a[v].add(new Pair(u, i));
			b[u].add(w);
			b[v].add(w);
		}
		int ind = ni() - 1;
		TreeSet<Pairs> set = new TreeSet<Pairs>();
		long val[] = new long[n];
		Arrays.fill(val, (long) 1e16);
		val[ind] = 0;
		for (int i = 0; i < a[ind].size(); i++)
			set.add(new Pairs((long) b[ind].get(i), b[ind].get(i), (int) a[ind].get(i).u, (int) a[ind].get(i).v, ind));
		TreeSet<Integer> fin = new TreeSet<Integer>();
		long ans = 0;
		for (int j = 0; j < n - 1; j++) {
			Pairs p = set.pollFirst();
			if (find(p.id, p.pa)) {
				j--;
				continue;
			}
			union(p.id, p.pa);
			val[p.id] = p.u;
			ans += p.v;
			fin.add(p.p);
			for (int i = 0; i < a[p.id].size(); i++) {
				Pair k = a[p.id].get(i);
				if (val[p.id] + b[p.id].get(i) <= val[(int) k.u])
					set.add(new Pairs(val[p.id] + b[p.id].get(i), b[p.id].get(i), (int) k.u, (int) k.v, p.id));
			}
		}
		out.println(ans);
		while (!fin.isEmpty())
			out.print((fin.pollFirst() + 1) + " ");
		out.println();
	}

	void soln() {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new CODEFORCES().soln();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}