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;
template <class T>
void chmax(T& l, const T r) {
  l = max(l, r);
}
template <class T>
void chmin(T& l, const T r) {
  l = min(l, r);
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T extgcd(T a, T b, T& x, T& y) {
  for (T u = y = 1, v = x = 0; a;) {
    T q = b / a;
    swap(x -= q * u, u);
    swap(y -= q * v, v);
    swap(b -= q * a, a);
  }
  return b;
}
template <class T>
T mod_inv(T a, T m) {
  T x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
long long mod_pow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long p = a % mod;
  while (n) {
    if (n & 1) ret = ret * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return ret;
}
void reader(int& x) {
  int k, m = 0;
  x = 0;
  for (;;) {
    (k) = getchar_unlocked();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar_unlocked();
    if (k < '0' || k > '9') break;
    x = x * 10 + k - '0';
  }
  if (m) x = -x;
}
void reader(long long& x) {
  int k, m = 0;
  x = 0;
  for (;;) {
    (k) = getchar_unlocked();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar_unlocked();
    if (k < '0' || k > '9') break;
    x = x * 10 + k - '0';
  }
  if (m) x = -x;
}
int reader(char c[]) {
  int i, s = 0;
  for (;;) {
    (i) = getchar_unlocked();
    if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break;
  }
  c[s++] = i;
  for (;;) {
    (i) = getchar_unlocked();
    if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break;
    c[s++] = i;
  }
  c[s] = '\0';
  return s;
}
template <class T, class S>
void reader(T& x, S& y) {
  reader(x);
  reader(y);
}
template <class T, class S, class U>
void reader(T& x, S& y, U& z) {
  reader(x);
  reader(y);
  reader(z);
}
template <class T, class S, class U, class V>
void reader(T& x, S& y, U& z, V& w) {
  reader(x);
  reader(y);
  reader(z);
  reader(w);
}
void writer(int x, char c) {
  int s = 0, m = 0;
  char f[10];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar_unlocked('-');
  while (s--) putchar_unlocked(f[s] + '0');
  putchar_unlocked(c);
}
void writer(long long x, char c) {
  int s = 0, m = 0;
  char f[20];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar_unlocked('-');
  while (s--) putchar_unlocked(f[s] + '0');
  putchar_unlocked(c);
}
void writer(const char c[]) {
  int i;
  for (i = 0; c[i] != '\0'; i++) putchar_unlocked(c[i]);
}
void writer(const char x[], char c) {
  int i;
  for (i = 0; x[i] != '\0'; i++) putchar_unlocked(x[i]);
  putchar_unlocked(c);
}
template <class T>
void writerLn(T x) {
  writer(x, '\n');
}
template <class T, class S>
void writerLn(T x, S y) {
  writer(x, ' ');
  writer(y, '\n');
}
template <class T, class S, class U>
void writerLn(T x, S y, U z) {
  writer(x, ' ');
  writer(y, ' ');
  writer(z, '\n');
}
template <class T>
void writerArr(T x[], int n) {
  if (!n) {
    putchar_unlocked('\n');
    return;
  }
  for (int i = 0; i < (n - 1); i++) writer(x[i], ' ');
  writer(x[n - 1], '\n');
}
const long long INF = numeric_limits<long long>::max() / 10;
struct edge {
  int to;
  long long cost;
  edge() {}
  edge(int to, long long cost) : to(to), cost(cost) {}
};
void dijkstra(int s, vector<pair<long long, int>::first_type>& cost_table,
              vector<vector<edge>>& edges, vector<int>* _prev = NULL) {
  cost_table.resize((int)edges.size());
  fill(cost_table.begin(), cost_table.end(),
       pair<long long, int>::first_type(INF));
  if (_prev) _prev->resize((int)edges.size());
  if (_prev) fill(_prev->begin(), _prev->end(), -1);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      q;
  q.push(pair<long long, int>(0, s));
  cost_table[s] = 0;
  while (!q.empty()) {
    pair<long long, int> p = q.top();
    q.pop();
    int v = p.second;
    if (cost_table[v] < p.first) continue;
    for (int i = 0; i < (int)edges[v].size(); i++) {
      edge& e = edges[v][i];
      if (cost_table[e.to] > cost_table[v] + e.cost) {
        cost_table[e.to] = cost_table[v] + e.cost;
        if (_prev) (*_prev)[e.to] = v;
        q.push(pair<long long, int>(cost_table[e.to], e.to));
      }
    }
  }
}
vector<vector<edge>> e;
map<pair<int, int>, int> e2id;
class UnionFind {
 private:
  int n;
  vector<int> a;

 public:
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) { return a[x] < 0 ? x : (a[x] = find(a[x])); }
  bool same(int x, int y) { return find(x) == find(y); }
  bool same(pair<int, int>& p) { return same(p.first, p.second); }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    n--;
    return true;
  }
  bool unite(pair<int, int>& p) { return unite(p.first, p.second); }
  int size() const { return n; }
  int size(int x) { return -a[find(x)]; }
};
int main() {
  int n, m;
  reader(n, m);
  e.resize(n);
  vector<tuple<long long, int, int>> es;
  for (int i = 0; i < (m); i++) {
    int a, b, c;
    reader(a, b, c);
    a--;
    b--;
    e[a].emplace_back(b, c);
    e[b].emplace_back(a, c);
    es.emplace_back(c, a, b);
    e2id[pair<int, int>(a, b)] = i + 1;
    e2id[pair<int, int>(b, a)] = i + 1;
  }
  sort(es.begin(), es.end());
  int s;
  reader(s);
  s--;
  vector<pair<long long, int>::first_type> cost_table;
  dijkstra(s, cost_table, e);
  static bool connect_low[((int)1e5) * 3];
  UnionFind uf(n);
  long long ans = 0;
  vector<int> anses;
  for (auto& p : es) {
    long long cst;
    int from, to;
    tie(cst, from, to) = p;
    if (uf.same(from, to)) continue;
    if (cost_table[from] > cost_table[to]) swap(from, to);
    if (connect_low[to]) continue;
    if (cost_table[to] - cost_table[from] == cst) {
      connect_low[to] = true;
      uf.unite(from, to);
      ans += cst;
      anses.push_back(e2id[pair<int, int>(from, to)]);
    }
  }
  writerLn(ans);
  if (((int)(anses).size())) writerArr(&anses[0], ((int)(anses).size()));
}