#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
struct Edge {
  int to, next, id;
  long long w;
} edge[maxn * 2];
int first[maxn], sign;
void init() {
  memset(first, -1, sizeof(first));
  sign = 0;
}
void add_edge(int id, int u, int v, long long w) {
  edge[sign].id = id;
  edge[sign].to = v;
  edge[sign].w = w;
  edge[sign].next = first[u];
  first[u] = sign++;
}
struct point {
  int x, id;
  long long w;
  point() {}
  point(int xx, int iid, long long ww) { x = xx, id = iid, w = ww; }
  friend bool operator<(point a, point b) { return a.w > b.w; }
} now;
priority_queue<point> q;
vector<int> answer;
int MinLen[maxn], vis[maxn];
void dij(int n, int m) {
  for (int i = 1; i <= n; i++) MinLen[i] = -1;
  memset(vis, 0, sizeof(vis));
  q.push(point(1, 0, 0));
  while (!q.empty()) {
    now = q.top();
    q.pop();
    if (vis[now.x]) continue;
    MinLen[now.x] = now.w;
    vis[now.x] = 1;
    answer.push_back(now.id);
    for (int i = first[now.x]; ~i; i = edge[i].next) {
      q.push(point(edge[i].to, edge[i].id, edge[i].w + now.w));
    }
  }
  int ans = answer.size() - 1;
  ans = min(ans, m);
  printf("%d\n", ans);
  if (ans) printf("%d", answer[1]);
  for (int i = 2; i <= ans; i++) {
    printf(" %d", answer[i]);
  }
}
int main() {
  init();
  int n, m, k, x, y;
  long long w;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%I64d", &x, &y, &w);
    add_edge(i, x, y, w);
    add_edge(i, y, x, w);
  }
  dij(n, k);
  return 0;
}
