#include <bits/stdc++.h>
using namespace std;
int n, m, k;
unordered_map<int, vector<int> > g;
map<pair<int, int>, int> weights;
map<pair<int, int>, int> idx;
unordered_map<int, bool> used;
struct elem {
  int prev;
  int u;
  long long dist;
  elem(int prev, int u, long long dist) : prev(prev), u(u), dist(dist) {}
  friend bool operator<(const elem& lh, const elem& rh) {
    return lh.dist > rh.dist;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back(v);
    g[v].push_back(u);
    weights[make_pair(u, v)] = w;
    weights[make_pair(v, u)] = w;
    idx[make_pair(u, v)] = i;
    idx[make_pair(v, u)] = i;
  }
  vector<int> res;
  priority_queue<elem> q;
  q.push(elem(0, 1, 0));
  int taken = 0;
  int mx = min(n, k);
  while (!q.empty() && mx != taken) {
    int prev = q.top().prev;
    int u = q.top().u;
    long long dist = q.top().dist;
    q.pop();
    if (used[u]) continue;
    used[u] = true;
    if (prev) {
      res.push_back(idx[make_pair(prev, u)]);
      ++taken;
    }
    for (int v : g[u])
      if (!used[v]) {
        q.push(elem(u, v, dist + weights[make_pair(u, v)]));
      }
  }
  cout << res.size() << endl;
  for (int i : res) cout << i << " ";
  cout << endl;
  return 0;
}
