#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, pair<long long, long long> > > > G;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  G.resize(n + 1);
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    G[u].push_back({v, {w, i}});
    G[v].push_back({u, {w, i}});
  }
  set<pair<long long, long long> > q;
  q.insert({0, 0});
  long long cnt = 0;
  long long dis[n], last[n];
  fill(dis, dis + n, LLONG_MAX);
  dis[0] = 0;
  fill(last, last + n, -1);
  vector<long long> ans;
  while (q.empty() == false && cnt < k) {
    auto p = *q.begin();
    q.erase(q.begin());
    long long ver = p.second;
    dis[ver] = min(dis[ver], p.first);
    if (last[ver] != -1) {
      cnt++;
      ans.push_back(last[ver]);
    }
    for (auto y : G[ver]) {
      long long to = y.first;
      long long w = y.second.first;
      long long ind = y.second.second;
      if (dis[to] > dis[ver] + w) {
        q.erase({dis[to], to});
        dis[to] = dis[ver] + w;
        last[to] = ind;
        q.insert({dis[to], to});
      }
    }
  }
  cout << ans.size() << endl;
  for (auto val : ans) {
    cout << val + 1 << " ";
  }
  cout << endl;
  return 0;
}
