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 MainClass
{
    static int n, m;
    static ArrayList<Integer>[] adj;
    static ArrayList<Long>[] cost;
    static int start;
    static boolean[] visited;
    static long[] last;
    static long[] dist;
    static ArrayList<Integer>[] indices;
    static int[] edge;
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        n = in.nextInt();
        m = in.nextInt();
        edge = new int[n];
        adj = new ArrayList[n];
        cost = new ArrayList[n];
        indices = new ArrayList[n];
        visited = new boolean[n];
        last = new long[n];
        dist = new long[n];
        Arrays.fill(dist, Long.MAX_VALUE);
        Arrays.fill(last, Long.MAX_VALUE);
        for (int i=0;i<n;i++)
        {
            adj[i] = new ArrayList<>();
            cost[i] = new ArrayList<>();
            indices[i] = new ArrayList<>();
        }
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            long c = in.nextLong();
            adj[x].add(y);
            adj[y].add(x);
            cost[x].add(c);
            cost[y].add(c);
            indices[x].add(i);
            indices[y].add(i);
        }
        start = in.nextInt() - 1;
        edge[start] = -1;
        last[start] = 0L;
        dist[start] = 0L;
        PriorityQueue<Game> pq = new PriorityQueue<>();
        pq.add(new Game(start, 0L));
        while (!pq.isEmpty())
        {
            Game node = pq.poll();
            int v = node.v;
            if (visited[v]) continue;
            visited[v] = true;
            for (int i=0;i<adj[v].size();i++)
            {
                int to = adj[v].get(i);
                long w = cost[v].get(i);
                if (dist[v] + w < dist[to])
                {
                    Game g = new Game(to, dist[v] + w);
                    pq.add(g);
                    dist[to] = dist[v] + w;
                    last[to] = w;
                    edge[to] = indices[v].get(i);
                }
                else if (dist[v] + w == dist[to] && last[to] > w)
                {
                    last[to] = w;
                    edge[to] = indices[v].get(i);
                }
            }
        }
        long ans = 0L;
        for (int i=0;i<n;i++)
            ans += last[i];
        StringBuilder stringBuilder = new StringBuilder();
        for (int i=0;i<n;i++)   if (edge[i] != -1)
            stringBuilder.append(edge[i] + 1).append(" ");
        System.out.println(ans);
        System.out.println(stringBuilder);
    }
}
class Game implements Comparable<Game>
{
    int v;
    long val;

    public Game(int v, long val)
    {
        this.v = v;
        this.val = val;
    }

    @Override
    public int compareTo(Game ob)
    {
        return (int)(this.val - ob.val);
    }
}
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[64]; // line length
        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();
    }
}