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

import javax.lang.model.util.ElementScanner6;

public class B{

    static class Edge{
        int x;
        int wt;
        int e_no;
        Edge(int a,int w,int n){
            x = a;
            wt = w;
            e_no = n;
        }
    }
   public static void main(String ars[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        PrintWriter out = new PrintWriter(System.out);
        ArrayList<ArrayList<Edge>> graph = new ArrayList<>();
        for(int i=0;i<n;i++){
            graph.add(new ArrayList<Edge>());
        }

        for(int i=0;i<m;i++){
            int a = in.nextInt()-1;
            int b = in.nextInt()-1;
            int wt = in.nextInt();
            graph.get(a).add(new Edge(b,wt,i+1));
            graph.get(b).add(new Edge(a,wt,i+1));
        }

        int u = in.nextInt()-1;

        long dis[] = new long[n];
        Arrays.fill(dis,Long.MAX_VALUE/2);
        int par[] = new int[n];
        vis = new boolean[n];
        Arrays.fill(par,-1);
        long min_wt = 0;
        dijkstra(graph,u,dis,par);
        List<Integer> ans = new ArrayList<>();
        for(int i=0;i<n;i++){
            ArrayList<Edge> temp = graph.get(i);
            for(int j=0;j<temp.size();j++){
                Edge child = temp.get(j);
                if(child.x==par[i]){
                    ans.add(child.e_no);
                    min_wt+=child.wt;
                }
            }
        }
        Collections.sort(ans);
        System.out.println(min_wt);
        //System.out.println(Arrays.toString(last));
        for(int i=0;i<ans.size();i++)
            out.print(ans.get(i)+" ");
        out.close();
        in.close();
   }

   static boolean vis[];
   public static void dijkstra(ArrayList<ArrayList<Edge>> graph,int src,long []dis,int []par){
        PriorityQueue<Integer> pq = new PriorityQueue<>(1000000,new Comparator<Integer>() {
            public int compare(Integer a,Integer b){
                if(dis[a]>dis[b])
                    return 1;
                else if(dis[a]<dis[b])
                    return -1;
                else
                    return 0;
            }
        });
        int n = dis.length;
        pq.add(src);
        dis[src] = 0;
        while(!pq.isEmpty() ){
            int curr = pq.poll();
            //if(vis[curr])
              //  continue;
            vis[curr] = true;
            ArrayList<Edge> temp = graph.get(curr);
            for(int i=0;i<temp.size();i++){
                Edge child = temp.get(i);
                if((dis[child.x]>dis[curr]+child.wt )){
                    dis[child.x] = dis[curr]+child.wt;
                    par[child.x] = curr;
                    pq.add(child.x);
                }
                else if((dis[child.x] == dis[curr]+child.wt ))
                if( (dis[curr]>dis[par[child.x]])){
                    par[child.x] = curr;
                }
            }
        }
   }


}