#include <bits/stdc++.h>
const int N = 3e5 + 5;
std::vector<std::array<long long, 3> > g[N];
std::vector<std::pair<long long, long long> > g2[N];
struct Edge {
  long long u;
  long long v;
  long long w;
};
Edge edges[N];
int sz[N];
std::vector<std::pair<long long, long long> > esz;
void dfs(int u, int p) {
  sz[u] = 1;
  for (auto v : g2[u]) {
    if (v.first != p) {
      dfs(v.first, u);
      sz[u] += sz[v.first];
      esz.push_back({sz[v.first], v.second});
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, k;
  std::cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    std::cin >> u >> v >> w;
    --u;
    --v;
    if (u > v) std::swap(u, v);
    edges[i].u = u;
    edges[i].v = v;
    edges[i].w = w;
    g[u].push_back({v, w, i});
    g[v].push_back({u, w, i});
  }
  std::vector<bool> visited(n, false);
  std::priority_queue<std::array<long long, 3>,
                      std::vector<std::array<long long, 3> >,
                      std::greater<std::array<long long, 3> > >
      pq;
  pq.push({0, 0, -1});
  std::vector<int> eidx;
  while (!pq.empty()) {
    auto u = pq.top();
    pq.pop();
    if (visited[u[1]]) {
      continue;
    }
    visited[u[1]] = true;
    if (u[2] != -1) {
      eidx.push_back(u[2]);
    }
    for (auto v : g[u[1]]) {
      if (!visited[v[0]]) {
        pq.push({u[0] + v[1], v[0], v[2]});
      }
    }
  }
  if (eidx.size() <= k) {
    std::cout << eidx.size() << std::endl;
    for (int i = 0; i < n - 1; i++) {
      std::cout << eidx[i] + 1 << " ";
    }
    std::cout << std::endl;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int u = edges[eidx[i]].u;
    int v = edges[eidx[i]].v;
    g2[u].push_back({v, eidx[i]});
    g2[v].push_back({u, eidx[i]});
  }
  dfs(0, 0);
  sort(esz.begin(), esz.end(),
       std::greater<std::pair<long long, long long> >());
  std::cout << k << std::endl;
  for (int i = 0; i < k; i++) {
    std::cout << esz[i].second + 1 << " ";
  }
  std::cout << std::endl;
  return 0;
}
