#include <bits/stdc++.h>
const int inf = 1e9 + 9;
const int N = 5e5 + 5;
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
struct node {
  int nxt, to, w;
} e[N << 1];
int head[N], n, m, k, pre[N], vis[N], tot = 1;
inline void add(int x, int y, int w) {
  e[++tot] = node{head[x], y, w}, head[x] = tot;
}
long long dis[N];
vector<int> ans;
priority_queue<pair<long long, int> > q;
void init() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), w = read();
    add(x, y, w), add(y, x, w);
  }
}
void dij() {
  for (int i = 2; i <= n; i++) dis[i] = 1e15;
  q.push(make_pair(0, 1));
  while (!q.empty() && ans.size() < k) {
    int u = q.top().second;
    q.pop();
    if (vis[u]) continue;
    if (u ^ 1) ans.push_back(pre[u] / 2);
    vis[u] = 1;
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to, w = e[i].w;
      if (dis[v] > dis[u] + w) {
        dis[v] = dis[u] + w, pre[v] = i;
        q.push(make_pair(-dis[v], v));
      }
    }
  }
}
void solve() {
  dij();
  k = ans.size();
  printf("%d\n", k);
  for (int i = 0; i < k; i++) printf("%d ", ans[i]);
}
int main() {
  init();
  solve();
  return 0;
}
