#include <bits/stdc++.h>
using namespace std;
const long long MAXV = 2 * 300005;
const long long INF = 2e18;
struct edge {
  long long id, to, cost;
  edge(long long id, long long to, long long cost)
      : id(id), to(to), cost(cost) {}
};
vector<edge> G[MAXV];
long long d[MAXV];
long long pre[MAXV];
long long id[MAXV];
vector<long long> son[MAXV];
bool vis[MAXV];
long long V, E, k;
long long ans[MAXV];
long long cnt = 0;
void dijkstra() {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(pair<long long, long long>(0, 1));
  fill(d, d + V + 1, INF);
  fill(vis, vis + V + 1, false);
  fill(pre, pre + V + 1, -1);
  d[1] = 0;
  while (!pq.empty()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    long long v = p.second;
    if (vis[v]) continue;
    vis[v] = true;
    for (long long i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (!vis[e.to] && d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        pq.push(pair<long long, long long>(d[e.to], e.to));
        pre[e.to] = v;
        id[e.to] = e.id;
      }
    }
  }
}
void build() {
  for (long long i = 2; i <= V; i++) {
    son[pre[i]].push_back(i);
  }
}
void dfs(long long s) {
  if (k <= 0) return;
  for (long long i = 0; i < son[s].size() && k > 0; i++) {
    ans[cnt++] = id[son[s][i]];
    k--;
    if (k <= 0) {
      break;
    }
    dfs(son[s][i]);
  }
}
int main() {
  scanf("%lld%lld%lld", &V, &E, &k);
  for (long long i = 1; i <= E; i++) {
    long long u, v, c;
    scanf("%lld%lld%lld", &u, &v, &c);
    G[u].push_back(edge(i, v, c));
    G[v].push_back(edge(i, u, c));
  }
  dijkstra();
  build();
  dfs(1);
  printf("%lld\n", cnt);
  for (long long i = 0; i < cnt - 1; i++) {
    printf("%lld ", ans[i]);
  }
  if (cnt != 0) {
    printf("%lld", ans[cnt - 1]);
  }
  return 0;
}
