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

public class Task {
		
	public static void main(String[] args) throws IOException {
		new Task().solve();
	}
	
	PrintWriter out;
	int cnt = 0;
	int n;
	boolean[] used;
	int[] use;
	ArrayList<Item>[] gr;
	ArrayList<Integer> tsort = new ArrayList<Integer>();
	int[] comp;
	int[] compsize;
	int[] mt;
	int[] a;
	int k;
	boolean[][] g;
	long dp[];
	int m;
	int[] list;
	int d;
	int ver = 0;
	int mod = 1000000007;
	void solve() throws IOException{
		Reader in = new Reader("output.txt");
		out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(System.out)) );
		//out = new PrintWriter(new FileWriter(new File("output.txt"))); 
		
		int n = in.nextInt();
		int m = in.nextInt();
		
		//Item[] a = new Item[m];
		
		gr = new ArrayList[n];
		list = new int[n];
		for (int i = 0; i < n; i++)
			gr[i] = new ArrayList<Item>();
		
		LinkedList<Item> all = new LinkedList<Item>();
		
		for (int i = 0; i < m; i++) {
			int x = in.nextInt()-1;
			int y = in.nextInt()-1;
			int w = in.nextInt();
			gr[x].add(new Item(y,y,w));
			gr[y].add(new Item(x,x,w));
			all.add(new Item(x,y,w));
		}

		dp = new long[n];
		Arrays.fill(dp, Long.MAX_VALUE-1);
		int start = in.nextInt()-1;
		dp[start] = 0;
		list[start] = -1;
		PriorityQueue<Item> queue = new PriorityQueue<>();
		
		queue.add(new Item(start, start, 0));
		
		while (!queue.isEmpty()) {
			Item it = queue.poll();
			int v = it.a;
			long w = it.u;
			
			for (Item item : gr[v]) {
				if (dp[v]+item.u < dp[item.a]) {
					queue.add(new Item(item.a, 0, dp[v]+item.u));
					dp[item.a] = dp[v]+item.u;
					list[item.a] = v;
				}
				else
				if (dp[v]+item.u == dp[item.a] && dp[item.a]-dp[list[item.a]] > dp[item.a]-dp[v]) {
					list[item.a] = v;
				}
			}
			
		}
		//System.out.println(dp[2]);
		//dfs(start, 0, -1);
		res = 0;
		
		LinkedList<Integer> edges = new LinkedList<Integer>();
		
		for (int i = 0; i < m; i++) {
			Item item = all.removeFirst();
			if (list[item.a] == item.b) {
				res += item.u;
				edges.add(i);
			}
			else
			if (list[item.b] == item.a) {
				res += item.u;
				edges.add(i);
			}	
			//System.out.println(dp[i]);
		}
		
		//System.out.println(dp[4]);
		
		out.println(res);
		for (int k : edges)
			out.print((k+1)+" ");
		out.flush();
		out.close();
		
	}
	
	long res = 0;
	
	
	void dfs(int v, long p, int par) {
		//System.out.println(v+" "+par+" "+p);
		if (dp[v] > p) {
			dp[v] = p;
			list[v] = par;
		}
		else
		if (dp[v] == p && dp[v]-dp[list[v]] > dp[v]-dp[par])
		{
			dp[v] = p;
			list[v] = par;
			return;
		}
		else
	    {
			//System.out.println(v+" "+dp[v]+" "+par+" "+p);
			return;
		}
		
	
		for (Item i : gr[v])
			if (i.a != par) {
				long w = dp[v]+i.u;
				i.b = -1;
				dfs(i.a, w, v);
			}
	}
	
	long pow(int x, int m) {
		if (m == 0)
			return 1;
		return x*pow(x, m-1);
	}

}
	
	class Pair implements Comparable<Pair> {
		
		long v;
		int i;
		
		Pair (long v, int i) {
			this.v = v;
			this.i = i;
		}

		@Override
		public int compareTo(Pair p) {
			if (v < p.v)
				return 1;
			if (v > p.v)
				return -1;
			return 0;
		}
		
	}

	class Item implements Comparable<Item> {

		int a;
		int b;
		long u;
		
		Item(int v, int l, long z) {
			this.a = v;
			this.b = l;
			this.u = z;
		}
		
		@Override
		public int compareTo(Item item) {
			
			if (u > item.u)
				return 1;
			else
			if (u < item.u)
				return -1;
			else {
				return 0;
			}
						
		}
		
	}
	
	class Reader {
	    
	    StringTokenizer token;
	    BufferedReader in;
	    
	    public Reader(String file) throws IOException {
	        //in = new BufferedReader( new FileReader( file ) );
	        in = new BufferedReader( new InputStreamReader( System.in ) );
	    }
	    
	    public byte nextByte() throws IOException {
	        return Byte.parseByte(Next());
	    }
	    
	    public int nextInt() throws IOException {
	        return Integer.parseInt(Next());
	    }
	    
	    public long nextLong() throws IOException {
	        return Long.parseLong(Next());
	    }
	    
	    public String nextString() throws IOException {
	        return in.readLine();
	    }
	    
	    public String Next() throws IOException {
	        while (token == null || !token.hasMoreTokens()) {
	            token = new StringTokenizer(in.readLine());
	        }
	        return token.nextToken();
	    }

	    
	}