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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
vector<long long> v[300009];
long long edges[3][300009], each_vertex[2][300009], taken[300009];
set<vector<long long> > st;
set<vector<long long> >::iterator it, erase_it;
int main() {
  long long t, n, m, a, b, u, weight, edge_idx, i, j, max_weight;
  max_weight = 1000000;
  max_weight *= max_weight;
  max_weight *= 1000;
  for (i = 0; i < 300009; ++i) v[i].clear();
  memset(edges, 0, sizeof(edges));
  memset(each_vertex, 0, sizeof(each_vertex));
  memset(taken, 0, sizeof(taken));
  st.clear();
  cin >> n >> m;
  for (i = 1; i <= m; ++i) {
    cin >> edges[0][i] >> edges[1][i] >> edges[2][i];
    v[edges[0][i]].push_back(i);
    v[edges[1][i]].push_back(i);
  }
  cin >> u;
  for (i = 1; i <= n; ++i) {
    vector<long long> temp;
    if (i == u)
      temp.push_back(0);
    else
      temp.push_back(max_weight);
    temp.push_back(0);
    temp.push_back(i);
    for (j = 0; j < 2; ++j) each_vertex[j][i] = temp[j];
    st.insert(temp);
  }
  while (!st.empty()) {
    it = st.begin();
    long long weight_till_now = (*it)[0];
    long long this_vertex = (*it)[2];
    taken[this_vertex] = 1;
    for (vector<long long>::iterator it_vector = v[this_vertex].begin();
         it_vector != v[this_vertex].end(); ++it_vector) {
      long long other_vertex =
          (this_vertex != edges[0][*it_vector] ? edges[0][*it_vector]
                                               : edges[1][*it_vector]);
      if (taken[other_vertex] == 0) {
        bool flag = false;
        if ((weight_till_now + edges[2][*it_vector]) <
            each_vertex[0][other_vertex]) {
          flag = true;
        } else if (((weight_till_now + edges[2][*it_vector]) ==
                    each_vertex[0][other_vertex]) &&
                   (edges[2][*it_vector] <
                    edges[2][each_vertex[1][other_vertex]])) {
          flag = true;
        }
        if (flag) {
          vector<long long> temp;
          temp.push_back(each_vertex[0][other_vertex]);
          temp.push_back(each_vertex[1][other_vertex]);
          temp.push_back(other_vertex);
          erase_it = st.find(temp);
          st.erase(erase_it);
          temp.clear();
          temp.push_back((weight_till_now + edges[2][*it_vector]));
          temp.push_back(*it_vector);
          temp.push_back(other_vertex);
          st.insert(temp);
          each_vertex[0][other_vertex] = weight_till_now + edges[2][*it_vector];
          each_vertex[1][other_vertex] = *it_vector;
        }
      }
    }
    st.erase(it);
  }
  long long sum = 0;
  for (i = 1; i <= n; ++i) {
    if (each_vertex[1][i] != 0) sum += edges[2][each_vertex[1][i]];
  }
  cout << sum << "\n";
  for (i = 1; i <= n; ++i) {
    if (each_vertex[1][i] != 0) cout << each_vertex[1][i] << " ";
  }
  return 0;
}