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.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;


public class Paths_And_Trees {

    public static void main(String[] args) throws IOException {
        // TODO Auto-generated method stub
Reader r=new Reader();
int n=r.nextInt();
Graph g=new Graph();
int m=r.nextInt();
List<Edge> graph[]=g.createGraph(n);
int edges[][]=new int[m][4];
for(int i=0;i<m;i++){
    edges[i][0]=i;
    edges[i][1]=r.nextInt()-1;
    edges[i][2]=r.nextInt()-1;
    edges[i][3]=r.nextInt();
    g.addEdge(graph, edges[i][1],edges[i][2],edges[i][3],edges[i][0]);
}
int src=r.nextInt()-1;
/*Arrays.sort(edges, new Comparator<int[]>() {

    @Override
    public int compare(int[] o1, int[] o2) {
        // TODO Auto-generated method stub
        if(o1[1]==o2[1])return o1[2]-o2[2];
        return o1[1]-o2[1];
    }
});
*/
g.Dijkstra(graph, src);

    }
    static class Edge {
        int t;long cost,id;

        public Edge(int t, long cost,long id) {
            super();
            this.t = t;
            this.cost = cost;
            this.id=id;
        }

    }
    static class MyComp implements Comparator<Edge>{

        @Override
        public int compare(Edge o1, Edge o2) {
            // TODO Auto-generated method stub
            return (int) (o1.cost-o2.cost);
        }
        
    }
    static class Graph {
        List<Edge> graph[];
        //int colour[];
        long distance[], min;
        boolean visited[];
        int parent[];
        public List<Edge>[] createGraph(int n) {
            graph = new List[n];
            //colour=new int[n];
            distance = new long[n];
            visited = new boolean[n];
            parent=new int[n];
            for (int i = 0; i < graph.length; i++)
                graph[i] = new ArrayList<Edge>();
            return graph;
        }

        public void addEdge(List<Edge> graph[], int s, int d, long capacity,int id) {
            graph[s].add(new Edge(d, capacity,id));
            graph[d].add(new Edge(s,capacity,id));
        }
        public void Dijkstra(List<Edge> graph[],int s){
            Arrays.fill(distance, Long.MAX_VALUE);
            distance[s]=0;
            parent[s]=-1;
            MyComp comp=new MyComp();
            PriorityQueue<Edge> pq=new PriorityQueue<Paths_And_Trees.Edge>(2*graph.length,comp);
            pq.add(new Edge(s,0,-1));
            while(!pq.isEmpty()){
                Edge edge=pq.poll();
                if(!visited[edge.t]){
                visited[edge.t]=true;
                    int size=graph[edge.t].size();
                    for(int i=0;i<size;i++){
                        Edge get=graph[edge.t].get(i);
                        int des=get.t;long cost=get.cost;
                        if(distance[des]>distance[edge.t]+cost){
                            distance[des]=distance[edge.t]+cost;
                            parent[des]=edge.t;
                            pq.add(new Edge(des, distance[des],-1));
                        }
                    }
                }
            }
            
            long sum=0;
            StringBuilder sb=new StringBuilder();
            for(int i=0;i<graph.length;i++){
                long res=Long.MAX_VALUE,id=-1;
                for(Edge e:graph[i]){
                    if(distance[e.t]+e.cost==distance[i] && e.cost<res){
                        id=e.id;
                        res=e.cost;
                    }
                }
                if(id!=-1){
                    sb.append((id+1)+" ");
                    sum+=res;
                }
            }
            System.out.println(sum);
            System.out.println(sb.toString());
        }
    }
static class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[1000000];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.')
            while ((c = read()) >= '0' && c <= '9')
                ret += (c - '0') / (div *= 10);
        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null)
            return;
        din.close();
    }
}
}