#include <bits/stdc++.h>
int N, M, K;
struct info {
  int node, idx;
  long long cost;
  bool operator<(const info &ref) const { return cost > ref.cost; }
};
long long D[300000 + 1];
int chk[300000 + 1];
std::vector<info> adj[300000 + 1];
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 0; i <= N; i++) {
    adj[i].clear();
    D[i] = 300000000000001ll;
  }
  for (int i = 1, f, t, c; i <= M; i++) {
    scanf("%d%d%d", &f, &t, &c);
    adj[f].push_back({t, i, c});
    adj[t].push_back({f, i, c});
    chk[i] = 0;
  }
  std::priority_queue<info> pque;
  pque.push({1, 0, 0});
  D[1] = 0;
  int k = -1;
  while (!pque.empty() && k < K) {
    info cur = pque.top();
    pque.pop();
    if (D[cur.node] != cur.cost) continue;
    k++;
    chk[cur.idx] = 1;
    for (info e : adj[cur.node]) {
      int nn = e.node;
      int ni = e.idx;
      long long nc = cur.cost + e.cost;
      if (D[nn] > nc) {
        D[nn] = nc;
        pque.push({nn, ni, nc});
      }
    }
  }
  printf("%d\n", k);
  for (int i = 1; i <= M; i++)
    if (chk[i] == 1) printf("%d ", i);
  printf("\n");
}
