#include <bits/stdc++.h>
using namespace std;
const int maxi = 3e5 + 7;
struct Edge {
  int to, w, id;
  Edge *nxt;
} * g[maxi], pool[maxi << 1], *cnp;
struct Node {
  int u;
  long long d;
  bool operator<(const Node &rhs) const { return rhs.d < d; }
};
int n, m, k;
long long d[maxi];
bool vis[maxi];
int ans[maxi], cnt;
void add_edge(int u, int v, int w, int id) {
  cnp->to = v;
  cnp->w = w;
  cnp->id = id;
  cnp->nxt = g[u];
  g[u] = cnp++;
}
void dij() {
  memset(d, 127, sizeof(d));
  d[1] = 0;
  priority_queue<Node> q;
  Node x;
  q.push((Node){1, 0});
  while (!q.empty()) {
    x = q.top();
    q.pop();
    if (vis[x.u]) continue;
    vis[x.u] = 1;
    for (Edge *p = g[x.u]; p; p = p->nxt)
      if (x.d + p->w < d[p->to]) {
        d[p->to] = x.d + p->w;
        q.push((Node){p->to, d[p->to]});
      }
  }
}
void dfs(int now) {
  vis[now] = 1;
  for (Edge *p = g[now]; p; p = p->nxt) {
    if (d[p->to] == d[now] + p->w && !vis[p->to]) {
      if (!k) return;
      --k;
      ans[++cnt] = p->id;
      dfs(p->to);
    }
  }
}
int main() {
  cnp = pool;
  scanf("%d %d %d", &n, &m, &k);
  int u, v, w;
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %d", &u, &v, &w);
    add_edge(u, v, w, i);
    add_edge(v, u, w, i);
  }
  dij();
  memset(vis, 0, sizeof(vis));
  dfs(1);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; ++i) printf("%d ", ans[i]);
  putchar('\n');
  return 0;
}
