#include <bits/stdc++.h>
using namespace std;
long long i, j, k;
struct edge {
  long long d, i, wt;
  bool operator>(const edge& rhs) const { return wt > rhs.wt; }
};
vector<vector<edge>> graph;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  graph.resize(n);
  for (i = (0); i < (m); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    graph[a].push_back((edge{b, i + 1, c}));
    graph[b].push_back((edge{a, i + 1, c}));
  }
  if (k == 0) {
    cout << "0" << '\n';
    return 0;
  } else if (k == m) {
    cout << m << '\n';
    for (i = (1); i < (m + 1); i++) cout << i << " ";
    cout << '\n';
    return 0;
  }
  vector<long long> dist(n, 1000000000000000011LL);
  vector<long long> edgeme(n, -1);
  vector<bool> included(m + 1, false);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  vector<bool> visited(n, false);
  pq.push({0, 0});
  dist[0] = 0;
  long long count = 0;
  vector<long long> ans;
  long long iter = 0;
  while (!pq.empty()) {
    if (iter == n + 1) break;
    iter++;
    long long u = pq.top().second;
    while (visited[u] && !pq.empty()) {
      pq.pop();
      u = pq.top().second;
    }
    pq.pop();
    visited[u] = true;
    if (count == k) break;
    if (edgeme[u] != -1 && !included[edgeme[u]]) {
      ans.push_back(edgeme[u]);
      included[edgeme[u]] = true;
      count++;
    }
    if (count == k) break;
    for (auto it : graph[u]) {
      long long v = it.d;
      long long wt = it.wt;
      if (!visited[v] && dist[v] > dist[u] + wt) {
        edgeme[v] = it.i;
        dist[v] = dist[u] + wt;
        pq.push({dist[v], v});
      }
    }
  }
  cout << (int)((ans).size()) << '\n';
  for (i = (0); i < ((int)((ans).size())); i++) cout << ans[i] << " ";
  cout << '\n';
  return 0;
}
