#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
vector<vector<pair<long long, long long> > > graph;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> m >> k;
  k = min(k + 1, n);
  graph.resize(n);
  map<pair<long long, long long>, long long> smth;
  for (long long i = 0; i < m; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    graph[a].push_back({b, w});
    graph[b].push_back({a, w});
    smth[{a, b}] = i + 1;
    smth[{b, a}] = i + 1;
  }
  vector<long long> dist(n, 1e18), pr(n, -1);
  dist[0] = 0;
  set<pair<long long, long long> > all;
  for (long long i = 0; i < n; i++) all.insert({dist[i], i});
  long long cnt = 0;
  set<long long> best;
  while (cnt < k) {
    cnt++;
    auto kek = *all.begin();
    all.erase(all.begin());
    long long v = kek.second;
    best.insert(v);
    for (auto lol : graph[v]) {
      long long to = lol.first;
      long long w = lol.second;
      if (dist[to] > dist[v] + w) {
        all.erase({dist[to], to});
        dist[to] = dist[v] + w;
        all.insert({dist[to], to});
        pr[to] = v;
      }
    }
  }
  cout << k - 1 << "\n";
  for (long long i = 0; i < n; i++) {
    if (pr[i] != -1 && best.find(i) != best.end()) {
      cout << smth[{i, pr[i]}] << " ";
    }
  }
  cout << "\n";
  return 0;
}
