#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000005;
vector<tuple<long long, int, int> > v[MAXN];
bool bio[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--, b--;
    v[a].emplace_back(-w, b, i + 1);
    v[b].emplace_back(-w, a, i + 1);
  }
  priority_queue<tuple<long long, int, int> > pq;
  pq.emplace(0, 0, 0);
  vector<int> rj;
  while (!pq.empty() && rj.size() < k) {
    int node, e;
    long long w;
    tie(w, node, e) = pq.top();
    pq.pop();
    if (bio[node]) continue;
    if (e) rj.push_back(e);
    bio[node] = 1;
    for (tuple<long long, int, int> x : v[node]) {
      long long nw;
      int nn, ne;
      tie(nw, nn, ne) = x;
      pq.emplace(nw + w, nn, ne);
    }
  }
  cout << rj.size() << "\n";
  for (auto x : rj) cout << x << " ";
}
