#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = 6e5 + 5;
int n, m, k, x, y, w;
int tot = 1, to[M], v[M], nex[M], head[N];
long long dis[N];
bool vis[N];
struct node {
  int dot;
  long long dis;
};
struct cmp {
  bool operator()(node a, node b) { return a.dis > b.dis; }
};
priority_queue<node, vector<node>, cmp> q;
void add(int x, int y, int w) {
  to[++tot] = y;
  v[tot] = w;
  nex[tot] = head[x];
  head[x] = tot;
}
void dij() {
  memset(dis, 63, sizeof(dis));
  dis[1] = 0;
  q.push((node){1, 0});
  while (!q.empty()) {
    int x = q.top().dot;
    q.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    for (int i = head[x]; i; i = nex[i]) {
      int y = to[i], w = v[i];
      if (dis[y] > dis[x] + w) {
        dis[y] = dis[x] + w;
        q.push((node){y, dis[y]});
      }
    }
  }
}
void dfs(int x) {
  if (k == 0) return;
  vis[x] = 1;
  for (int i = head[x]; i; i = nex[i]) {
    if (k == 0) return;
    int y = to[i], w = v[i];
    if (vis[y]) continue;
    if (dis[y] == dis[x] + w) {
      printf("%d ", i / 2);
      k--;
      dfs(y);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &w);
    add(x, y, w);
    add(y, x, w);
  }
  dij();
  if (k < n)
    printf("%d\n", k);
  else
    printf("%d\n", n - 1);
  memset(vis, 0, sizeof(vis));
  dfs(1);
  return 0;
}
