#include <bits/stdc++.h>
struct edge {
  int to, w;
  edge(int to_, int w_) {
    to = to_;
    w = w_;
  }
};
const int N = 300000;
int n, m, k;
std::vector<int> g[N];
std::vector<edge> e;
long long dist[N];
std::pair<long long, int> dv[N];
bool key[N];
int p[N];
void add_edge(int a, int b, int c) {
  g[a].push_back(e.size());
  e.push_back(edge(b, c));
  g[b].push_back(e.size());
  e.push_back(edge(a, c));
}
void find_paths() {
  memset(dist, 0x3f, 8 * n);
  dist[0] = 0;
  std::set<std::pair<long long, int> > s;
  s.insert(std::make_pair(0, 0));
  while (!s.empty()) {
    long long cur_dist = s.begin()->first;
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int i = 0; i < (int)g[v].size(); ++i)
      if (dist[e[g[v][i]].to] > cur_dist + e[g[v][i]].w) {
        s.erase(std::make_pair(dist[e[g[v][i]].to], e[g[v][i]].to));
        dist[e[g[v][i]].to] = cur_dist + e[g[v][i]].w;
        s.insert(std::make_pair(dist[e[g[v][i]].to], e[g[v][i]].to));
        p[e[g[v][i]].to] = (g[v][i] & ~1);
      }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    add_edge(a - 1, b - 1, c);
  }
  find_paths();
  for (int i = 1; i < n; ++i) key[p[i] >> 1] = true;
  k = m - k;
  for (int i = 0; i < m && k > 0; ++i)
    if (!key[i]) {
      --k;
      e[i * 2].w = e[i * 2 + 1].w = -1;
    }
  if (k > 0) {
    for (int i = 0; i < n; ++i) dv[i] = std::make_pair(dist[i], i);
    std::sort(dv, dv + n);
    for (int i = n - 1; i >= 0 && k > 0; --i) {
      int v = dv[i].second;
      e[p[v]].w = e[p[v] ^ 1].w = -1;
      --k;
    }
  }
  std::vector<int> ans;
  for (int i = 0; i < m; ++i)
    if (e[i * 2].w != -1) ans.push_back(i);
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) printf("%d ", ans[i] + 1);
  printf("\n");
  return 0;
}
