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;
const double PI = 2.0 * acos(0.0);
const double E = exp(1);
template <class T1>
void deb(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << endl;
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << endl;
}
template <typename T>
inline T sqr(T n) {
  return n * n;
}
inline double hypot(double x, double y) { return sqrt(sqr(x) + sqr(y)); }
template <typename T>
inline T pmod(T n, T m) {
  return ((n % m) + m) % m;
}
template <typename T>
T power(T n, int p) {
  return (p == 0) ? (T)(1) : (sqr(power(n, p >> 1)) * ((p & 1) * (n - 1) + 1));
}
template <typename T>
T bigmod(T n, int p, T m) {
  return (p == 0)
             ? (T)(1)
             : ((sqr(bigmod(n, p >> 1, m)) % m) * ((p & 1) * (n - 1) % m + 1)) %
                   m;
}
struct node {
  int u;
  long long w;
  long long sum = 0;
  node() {}
  node(int _u, long long _w, long long _s) : u(_u), w(_w), sum(_s) {}
  bool operator<(const node& p) const { return w > p.w; }
};
int n, m, p;
int par[3 * 100005];
pair<long long, long long> dist[300006];
vector<pair<int, int> > adj[3 * 100005];
bool vis[300005];
map<pair<int, int>, pair<int, int> > mk;
long long sum_edge;
map<pair<int, int>, int> res;
void dijkstra(int s) {
  for (int i = 0; i <= 300000; i++)
    dist[i].first = dist[i].second = (1ll << 50);
  dist[s].first = dist[s].second = 0;
  priority_queue<node> q;
  node tmp;
  int u, v;
  long long w;
  q.push(node(s, 0, 0));
  while (q.empty() == false) {
    u = q.top().u;
    w = q.top().w;
    q.pop();
    for (int i = 0; i < (int)adj[u].size(); i++) {
      v = adj[u][i].first;
      long long cst = (long long)adj[u][i].second;
      if (dist[v].first > dist[u].first + cst) {
        dist[v].first = dist[u].first + cst;
        dist[v].second = (long long)cst;
        q.push(node(v, dist[v].first, dist[v].second));
        if (par[v] == 0) {
          par[v] = u;
          sum_edge += cst;
          res[make_pair(u, v)] = mk[make_pair(u, v)].first;
          res[make_pair(v, u)] = mk[make_pair(u, v)].first;
        } else {
          int tu = par[v];
          int tv = v;
          res[make_pair(tv, tu)] = 0;
          res[make_pair(tu, tv)] = 0;
          sum_edge -= mk[make_pair(tu, tv)].second;
          sum_edge += cst;
          par[v] = u;
          res[make_pair(u, v)] = mk[make_pair(u, v)].first;
          res[make_pair(v, u)] = mk[make_pair(u, v)].first;
        }
      } else if (dist[v].first == dist[u].first + cst && dist[v].second > cst) {
        dist[v].first = dist[u].first + cst;
        dist[v].second = (long long)cst;
        q.push(node(v, dist[v].first, dist[v].second));
        if (par[v] == 0) {
          par[v] = u;
          sum_edge += cst;
          res[make_pair(u, v)] = mk[make_pair(u, v)].first;
          res[make_pair(v, u)] = mk[make_pair(u, v)].first;
        } else {
          int tu = par[v];
          int tv = v;
          res[make_pair(tv, tu)] = 0;
          res[make_pair(tu, tv)] = 0;
          sum_edge -= mk[make_pair(tu, tv)].second;
          sum_edge += cst;
          par[v] = u;
          res[make_pair(u, v)] = mk[make_pair(u, v)].first;
          res[make_pair(v, u)] = mk[make_pair(u, v)].first;
        }
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  int u, v, w;
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &u, &v, &w);
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
    mk[make_pair(u, v)] = make_pair(i + 1, w);
    mk[make_pair(v, u)] = make_pair(i + 1, w);
  }
  int s;
  scanf("%d", &s);
  dijkstra(s);
  deb(sum_edge);
  for (auto it = res.begin(); it != res.end(); it++) {
    if (it->second > 0) vis[it->second] = 1;
  }
  for (int i = 1; i <= m; ++i)
    if (vis[i]) printf("%d ", i);
  printf("\n");
}