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>
const int N = 300010;
const long long INF = 1ll << 60;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
std::vector<int> ans;
std::map<std::pair<int, int>, int> ma;
int a[N];
int b[N];
int c[N];
long long ans_val;
class Graph {
 public:
  void Init(int n) {
    e_.clear();
    e_.push_back(Edge(0, 0, 1, 0));
    m_ = 0;
    n_ = n;
    hd_.assign(n + 1, 0);
    vis_.assign(n + 1, false);
    connected_num_ = 0;
    for (int i = 1; i <= n; ++i) {
      deg_in_[i] = 0;
    }
  }
  void Init(int n, long long w[]) {
    e_.clear();
    e_.push_back(Edge(0, 0, 1, 0));
    m_ = 0;
    n_ = n;
    hd_.assign(n + 1, 0);
    vis_.assign(n + 1, false);
    connected_num_ = 0;
    for (int i = 1; i <= n; ++i) {
      deg_in_[i] = 0;
      weight[i] = w[i];
    }
  }
  void Add(int u, int v, long long w = 1ll, int type = 0) {
    Edge edge(v, hd_[u], w, type);
    e_.push_back(edge);
    hd_[u] = ++m_;
    ++deg_in_[v];
  }
  int Head(int id_v) { return hd_[id_v]; }
  int Next(int id_e) { return e_[id_e].nxt; }
  int To(int id_e) { return e_[id_e].v; }
  long long& W(int id_e) { return e_[id_e].w; }
  int& Type(int id_e) { return e_[id_e].type; }
  int NumNode() { return n_; }
  long long WNode(int u) { return weight[u]; }

 private:
  struct Edge {
    int v, nxt;
    long long w;
    int type;
    Edge(int _v, int _nxt, long long _w, int _type)
        : v(_v), nxt(_nxt), w(_w), type(_type) {}
  };
  int n_;
  std::vector<int> hd_;
  long long weight[N];
  int m_;
  std::vector<Edge> e_;
  std::vector<bool> vis_;
  int deg_in_[N];
  int connected_num_;
} graph;
class Dijkstra {
 public:
  Dijkstra() {}
  void Init(int n) {
    for (int i = 1; i <= n; ++i) {
      dis_[i] = -1;
      vis_[i] = false;
      num_[i] = 0;
    }
    while (!q_.empty()) {
      q_.pop();
    }
  }
  void InitState(int sta, long long dis) {
    q_.push((HeapNode){sta, dis});
    dis_[sta] = dis;
    num_[sta] = 1ll;
  }
  void Solve(Graph& graph) {
    while (!q_.empty()) {
      HeapNode x = q_.top();
      q_.pop();
      int& sta = x.sta;
      long long& dis = x.dis;
      if (vis_[sta]) {
        continue;
      }
      assert(dis == dis_[sta]);
      vis_[sta] = true;
      for (int i = graph.Head(sta); i; i = graph.Next(i)) {
        int sta_nxt = graph.To(i);
        long long w = graph.W(i);
        if (dis_[sta_nxt] == -1ll || dis_[sta_nxt] > dis_[sta] + w) {
          dis_[sta_nxt] = dis_[sta] + w;
          num_[sta_nxt] = num_[sta];
          q_.push((HeapNode){sta_nxt, dis_[sta_nxt]});
          pre_[sta_nxt] = sta;
          pre_min_[sta_nxt] = w;
        } else if (dis_[sta_nxt] == dis_[sta] + w) {
          num_[sta_nxt] = (num_[sta_nxt] + num_[sta]) % mod;
          if (pre_min_[sta_nxt] > w) {
            pre_[sta_nxt] = sta;
            pre_min_[sta_nxt] = w;
          }
        }
      }
    }
    ans.clear();
    ans_val = 0ll;
    for (int u = 1; u <= graph.NumNode(); ++u) {
      if (pre_[u]) {
        ans.push_back(ma[{u, pre_[u]}]);
        ans_val += c[ans.back()];
      }
    }
  }
  long long ShortestDis(int sta) { return dis_[sta]; }
  long long ShortestNum(int sta) { return num_[sta]; }

 private:
  struct HeapNode {
    int sta;
    long long dis;
    bool operator<(const HeapNode& rhs) const { return dis > rhs.dis; }
  };
  std::priority_queue<HeapNode> q_;
  long long dis_[N];
  bool vis_[N];
  long long num_[N];
  long long pre_min_[N];
  int pre_[N];
} dij;
int t;
int n, m;
int x;
int main() {
  scanf("%d%d", &n, &m);
  graph.Init(n);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    graph.Add(b[i], a[i], c[i]);
    graph.Add(a[i], b[i], c[i]);
    ma[{a[i], b[i]}] = i;
    ma[{b[i], a[i]}] = i;
  }
  scanf("%d", &x);
  dij.Init(n);
  dij.InitState(x, 0);
  dij.Solve(graph);
  printf("%lld\n", ans_val);
  for (size_t i = 0; i < ans.size(); ++i) {
    printf("%d%s", ans[i], i == ans.size() - 1 ? "\n" : " ");
  }
  return 0;
}