#include <bits/stdc++.h>
using namespace std;
int n, m, k, lt, num, p[1000005], hd[1000005], u, v, w, ent, i, vi[1000005];
long long d[1000005];
struct N {
  long long d;
  int u;
  bool operator<(const N &rhs) const { return d > rhs.d; }
};
struct edge {
  int v, nt, id;
  long long w;
  edge(int v = 0, int nt = 0, long long w = 0, int id = 0)
      : v(v), nt(nt), w(w), id(id) {}
} E[1000005];
void add(int u, int v, long long w, int id) {
  E[++ent] = edge(v, hd[u], w, id);
  hd[u] = ent;
}
void dj() {
  priority_queue<N> Q;
  for (int i = 0; i <= n; i++) {
    d[i] = 1e18;
    vi[i] = 0;
  }
  d[1] = 0;
  Q.push(N{0, 1});
  while (!Q.empty()) {
    N x = Q.top();
    Q.pop();
    int u = x.u;
    if (vi[u]) continue;
    vi[u] = 1;
    for (int i = hd[u]; ~i; i = E[i].nt) {
      edge &e = E[i];
      if (d[e.v] > d[u] + e.w) {
        d[e.v] = d[u] + e.w;
        p[e.v] = i;
        Q.push(N{d[e.v], e.v});
      }
    }
  }
}
void dfs(int u, int fa) {
  for (int i = hd[u]; ~i; i = E[i].nt) {
    int v = E[i].v;
    if (v == fa) continue;
    if (p[v] == i && num < lt) {
      num++;
      printf("%d ", E[i].id);
      dfs(v, u);
    }
  }
  return;
}
int main() {
  cin >> n >> m >> k;
  for (i = 0; i <= n; i++) hd[i] = -1;
  ent = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    add(u, v, w, i);
    add(v, u, w, i);
  }
  dj();
  lt = min(k, n - 1);
  num = 0;
  cout << lt << endl;
  dfs(1, 0);
}
