#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, k, i, w, cnt, u, size, v;
  cin >> n >> m >> k;
  vector<pair<pair<long long int, long long int>, long long int> > vec[n + 2];
  vector<long long> dist(n + 2, 1e18);
  for (i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    vec[u].push_back(make_pair(make_pair(v, w), i));
    vec[v].push_back(make_pair(make_pair(u, w), i));
  }
  cnt = 0;
  set<pair<long long, long long> > pq;
  pq.insert(make_pair(0, 1));
  dist[1] = 0;
  vector<long long> ans;
  vector<long long> parent(n + 2, 0);
  parent[1] = -1;
  while (cnt < k && !pq.empty()) {
    pair<long long, long long> z = *pq.begin();
    pq.erase(pq.begin());
    u = z.second;
    if (u != 1) {
      ans.push_back(parent[u]);
      cnt++;
    }
    size = vec[u].size();
    for (i = 0; i < size; i++) {
      v = vec[u][i].first.first;
      w = vec[u][i].first.second;
      if (dist[v] > dist[u] + w) {
        pq.erase(make_pair(dist[v], v));
        dist[v] = dist[u] + w;
        parent[v] = vec[u][i].second;
        pq.insert(make_pair(dist[v], v));
      }
    }
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
