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>
struct heap_t {
  long long w;
  int data, edge_index;
} heap[300000 + 10];
int heap_len;
int N, M;
void heap_print() {
  int i;
  printf("Heap:");
  for (i = 0; i < heap_len; i++)
    printf(" %d(%d)", heap[i].data + 1, heap[i].edge_index);
  printf("\n");
}
void heap_swap(int i, int j) {
  struct heap_t tmp;
  tmp = heap[i];
  heap[i] = heap[j];
  heap[j] = tmp;
}
void heap_add(long long w, int data, int edge_index) {
  int i;
  if (w < 0) {
    printf("Error: negative weight heap_add(%I64d,%d,%d)\n", w, data,
           edge_index);
    exit(0);
  }
  if (heap_len >= 300000 + 10) {
    printf("Error: maximum heap length exceeded\n");
    exit(0);
  }
  heap[heap_len].w = w;
  heap[heap_len].data = data;
  heap[heap_len].edge_index = edge_index;
  i = heap_len;
  heap_len++;
  while (i && heap[i].w < heap[(i - 1) / 2].w) {
    heap_swap(i, (i - 1) / 2);
    i = (i - 1) / 2;
  }
}
void heap_get(long long *w, int *data) {
  int i, i1, i2;
  *w = heap[0].w;
  *data = heap[0].data;
  heap_len--;
  heap[0] = heap[heap_len];
  for (i = 0;;) {
    i1 = 2 * i + 1;
    i2 = 2 * i + 2;
    if (i2 < heap_len && heap[i2].w < heap[i1].w) i1 = i2;
    if (i1 < heap_len && heap[i1].w < heap[i].w) {
      heap_swap(i, i1);
      i = i1;
    } else
      break;
  }
}
struct neighlist_t {
  int neighbour;
  int len;
  int index;
  struct neighlist_t *next;
} * neighlist[300000];
char test_negative() {
  return 0;
  int i;
  struct neighlist_t *n;
  for (i = 0; i < N; i++)
    for (n = neighlist[i]; n; n = n->next)
      if (n->len < 0) {
        printf("Error: Negative edge %d(%d) between %d and %d\n", n->index,
               n->len, i + 1, n->neighbour + 1);
        return 1;
      }
  return 0;
}
void add_edge(int a, int b, int len, int index) {
  struct neighlist_t *n;
  if (test_negative()) {
    printf("before add_edge [%d] %d-%d (%d)\n", index, a + 1, b + 1, len);
    exit(0);
  }
  n = (struct neighlist_t *)malloc(sizeof(struct neighlist_t));
  n->next = neighlist[a];
  n->neighbour = b;
  n->len = len;
  n->index = index;
  if (test_negative()) {
    printf("before add_edge [%d] %d->%d (%d)\n", index, a + 1, b + 1, len);
    exit(0);
  }
  neighlist[a] = n;
  if (test_negative()) {
    printf("after add_edge [%d] %d->%d (%d)\n", index, a + 1, b + 1, len);
    exit(0);
  }
  n = (struct neighlist_t *)malloc(sizeof(struct neighlist_t));
  n->next = neighlist[b];
  n->neighbour = a;
  n->len = len;
  n->index = index;
  if (test_negative()) {
    printf("before add_edge [%d] %d<-%d (%d)\n", index, a + 1, b + 1, len);
    exit(0);
  }
  neighlist[b] = n;
  if (test_negative()) {
    printf("after add_edge [%d] %d<-%d (%d)\n", index, a + 1, b + 1, len);
    exit(0);
  }
}
long long dist[300000];
int main() {
  int i;
  int a, b, len, U, V;
  int ans[300000];
  int ans_len;
  long long ans_weight, d;
  struct neighlist_t *n, *best;
  scanf("%d %d\n", &N, &M);
  for (i = 0; i < N; i++) {
    neighlist[i] = NULL;
    dist[i] = -1;
  }
  for (i = 0; i < M; i++) {
    scanf("%d %d %d\n", &a, &b, &len);
    a--;
    b--;
    if (a < 0 || a >= N || b < 0 || b >= N || len < 0) {
      printf("Error: a = %d, b = %d, len = %d\n", a + 1, b + 1);
      return 0;
    }
    add_edge(a, b, len, i + 1);
  }
  scanf("%d\n", &U);
  U--;
  ans_len = ans_weight = 0;
  heap_len = 0;
  heap_add(0, U, 0);
  while (heap_len) {
    heap_get(&d, &V);
    if (V < 0 || V >= N) {
      printf("Error: V = %d\n", V);
      return 0;
    }
    if (d < 0) {
      printf("Error: negative distance %I64d at the vertex %d\n", d, V + 1);
      return 0;
    }
    if (dist[V] >= 0) continue;
    dist[V] = d;
    best = NULL;
    for (n = neighlist[V]; n; n = n->next) {
      if (dist[n->neighbour] < 0) {
        if (d + n->len < 0) {
          printf("Error: negative distance: %I64d+%d = %I64d\n", d, n->len,
                 d + n->len);
          return 0;
        }
        heap_add(d + n->len, n->neighbour, n->index);
      } else if (dist[n->neighbour] + n->len == d &&
                 (!best || best->len > n->len))
        best = n;
    }
    if (best) {
      ans_weight += best->len;
      ans[ans_len++] = best->index;
    }
  }
  printf("%I64d\n", ans_weight);
  for (i = 0; i < ans_len; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}