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.util.*;
import java.io.*;

public class Main {
	public static void main(String args[]) {new Main().run();}

	FastReader in = new FastReader();
	PrintWriter out = new PrintWriter(System.out);
	void run(){
		work();
		out.flush();
	}
	long mod=998244353;
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	void work() {//上右下左 0---7
		int n=ni(),m=ni();
		ArrayList<int[]>[] graph=(ArrayList<int[]>[])new ArrayList[n];
		long sum=0;
		for(int i=0;i<n;i++) {
			graph[i]=new ArrayList<>();
		}
		for(int i=0;i<m;i++) {
			int s=ni()-1,e=ni()-1,w=ni();
			graph[s].add(new int[] {e,w,i+1});
			graph[e].add(new int[] {s,w,i+1});
		}
		int s=ni()-1;
		boolean[] vis=new boolean[n];
		PriorityQueue<long[]> pq=new PriorityQueue<>(new Comparator<long[]>() {
			public int compare(long[] A1,long[] A2) {
				if(A1[1]==A2[1]) {
					return A1[3]-A2[3]<0?-1:1;
				}
				return A1[1]-A2[1]<0?-1:1;
			}
		});
		pq.add(new long[] {s,0,-1,0});//node,w,idx
		ArrayList<Integer> ret=new ArrayList<>();
		while(pq.size()>0) {
			long[] q=pq.poll();
			int node=(int)q[0];
			if(vis[node])continue;
			long cur=q[1];
			int idx=(int)q[2];
			long w1=q[3];
			sum+=w1;
			if(idx!=-1)ret.add(idx);
			vis[node]=true;
			for(int[] g:graph[node]) {
				int nn=g[0];
				int w=g[1];
				int idx2=g[2];
				if(!vis[nn]) {
					pq.add(new long[] {nn,w+cur,idx2,w});
				}
			}
		}
		out.println(sum);
		for(int r:ret) {
			out.print(r+" ");
		}
	}



	//input
	private ArrayList<Integer>[] ng(int n, int m) {
		ArrayList<Integer>[] graph=(ArrayList<Integer>[])new ArrayList[n];
		for(int i=0;i<n;i++) {
			graph[i]=new ArrayList<>();
		}
		for(int i=1;i<=m;i++) {
			int s=in.nextInt()-1,e=in.nextInt()-1;
			graph[s].add(e);
			graph[e].add(s);
		}
		return graph;
	}

	private int ni() {
		return in.nextInt();
	}

	private long nl() {
		return in.nextLong();
	}

	private long[] na(int n) {
		long[] A=new long[n];
		for(int i=0;i<n;i++) {
			A[i]=in.nextLong();
		}
		return A;
	}
	private int[] nia(int n) {
		int[] A=new int[n];
		for(int i=0;i<n;i++) {
			A[i]=in.nextInt();
		}
		return A;
	}
}	

class FastReader
{
	BufferedReader br;
	StringTokenizer st;

	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}


	public String next() 
	{
		while(st==null || !st.hasMoreElements())//回车，空行情况
		{
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	public int nextInt() 
	{
		return Integer.parseInt(next());
	}

	public long nextLong()
	{
		return Long.parseLong(next());
	}
}