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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

public class d1  extends PrintWriter {

    static BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
    // static Scanner s=new Scanner(System.in);
    d1 () { super(System.out); }
    public static void main(String[] args) throws IOException{
        d1  d1=new d1 ();d1.main();d1.flush();
    }
    void main() throws IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        StringBuffer sb = new StringBuffer();
        StringBuffer sb1 = new StringBuffer();
        PrintWriter out = new PrintWriter(System.out);
//        Scanner s=new Scanner(System.in);
     //   System.out.println(sb.length());
          String[] s1=s();
          int n=i(s1[0]);int m=i(s1[1]);
        ArrayList<Pair> [] adj=new ArrayList[n+1];
       HashMap<Integer,Integer>  []  no=new HashMap[n+1];
        for(int i=0;i<m;i++){
            String[] s2=s();
            int u=i(s2[0]);int v=i(s2[1]);long val=i(s2[2]);
            if(adj[u]==null) adj[u]=new ArrayList<>();
            if(adj[v]==null) adj[v]=new ArrayList<>();
            adj[u].add(new Pair(v,val,u,(int)val,(int)val));
            adj[v].add(new Pair(u,val,v,(int) val,(int) val));
            if(no[u]==null) no[u]=new HashMap<>();
            if(no[v]==null) no[v]=new HashMap<>();
            no[u].put(v,i+1);no[v].put(u,i+1);
        }
        int start=i(s()[0]);
        PriorityQueue<Pair> pq=new PriorityQueue<>(new Comparator<Pair>(){
            public int compare(Pair a,Pair b){
                if(a.val-b.val<0) return -1;
                if(a.val==b.val) return a.edgeVal-b.edgeVal;
                return 1;
            }
        });
        sbb=new StringBuffer();tans=0;
        pq.add(new Pair(start,0,-1,0,0));
        if(m>0) {
            dfs(adj, no, pq, new int[n + 1]);
            System.out.println(tans);
            System.out.println(sbb);
        }else System.out.println(0);  }StringBuffer sbb;long tans;
    public void dfs(ArrayList<Pair> [] adj,HashMap<Integer,Integer>[] no,PriorityQueue<Pair> pq,int[]vis){
        if(pq.isEmpty()) return;
        while(!pq.isEmpty()){
        Pair i=pq.poll();
        if(vis[i.a]==1) continue;
        vis[i.a]=1;long dis=i.val;
        tans+=i.edgeVal;
//            System.out.println(i.edgeVal);
            //    System.out.println(i.a+" "+i.b);
        if(i.b!=-1)
         sbb.append(no[i.a].get(i.b)+" ");
        for(Pair j:adj[i.a]){
            if(vis[j.a]==0){
                    pq.add(new Pair(j.a,dis+j.val,i.a,(int)j.val,Math.max((int)j.val,i.max)));
            }
        }
        }
    }

    public void sort(int[] a,int l,int h){
        if(l==h) return;
        int mid=(l+h)/2;

        sort(a,l,mid);
        sort(a,mid+1,h);
        merge(a,l,(l+h)/2,h);
    }
    void merge(int arr[], int l, int m, int r)
    {
        int n1 = m - l + 1;
        int n2 = r - m;
        int L[] = new int[n1];
        int R[] = new int[n2];
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];
        int i = 0, j = 0;
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            }
            else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }
    long[] st;
    void buildtree(int i,int s,int e,long[] a){
        if(s==e){
            st[i]=a[s];
            return;
        }
        int mid=(s+e)/2;
        buildtree(2*i,s,mid,a);
        buildtree(2*i+1,mid+1,e,a);
        st[i]=Math.min(st[2*i],st[2*(i)+1]);
    }
    long query(int i,int s,int e,int qs,int qe){
        if(qs>e||qe<s) return Integer.MIN_VALUE;
        if(s>=qs&&e<=qe) return st[i];
        int mid=(s+e)/2;
        long l=query(2*i,s,mid,qs,qe);
        long r=query(2*i+1,mid+1,e,qs,qe);
        return Math.max(l,r);
    }
    void pointupdate(int i,int s,int e,int qi,long ht){
        if(s==e){
            st[i]=ht;return;
        }
        int mid=(s+e)/2;
        if(qi<=mid) pointupdate(2*i,s,mid,qi,ht);
        else pointupdate(2*(i)+1,mid+1,e,qi,ht);
        st[i]=Math.max(st[2*i],st[2*i+1]);
    }

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
    static String[] s() throws IOException {
        return s.readLine().trim().split("\\s+");
    }

    static int i(String ss) {
        return Integer.parseInt(ss);
    }
    static long l(String ss) {
        return Long.parseLong(ss);
    }
}
class Student {
    int  l;long r;
    public Student(int l, long r) {
        this.l = l;
        this.r = r;
    }
    public String toString()
    {
        return this.l+" ";
    }
}
class Pair {
    int  a,b;long val;int edgeVal;int max;
    public Pair(int  a,long val,int b,int edgeVal,int max){
        this.a=a;this.b=b ; this.val=val;this.edgeVal=edgeVal;this.max=max;
    }
}
class Sortbyroll implements Comparator<Student> {

    public int compare(Student a, Student b){
        if(a.r<b.r) return -1;
        else if(a.r==b.r){
            if(a.r==b.r){
                return 0;
            }
            if(a.r<b.r) return -1;
            return 1;}
        return 1;  }
}