#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  long long w, x, y;
  vector<pair<long long, long long>> v[n + 1];
  map<pair<long long, long long>, long long> mapp;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y >> w;
    v[x].push_back(make_pair(y, w));
    v[y].push_back(make_pair(x, w));
    mapp[make_pair(x, y)] = i + 1;
    mapp[make_pair(y, x)] = i + 1;
  }
  long long d[n + 1];
  set<pair<long long, long long>> s;
  bool vis[n + 1];
  long long parent[n + 1];
  for (long long i = 0; i <= n; i++) {
    vis[i] = false;
    d[i] = 1e18;
  }
  d[1] = 0;
  parent[1] = 1;
  s.insert(make_pair(0, 1));
  long long cnt = 0;
  while (!s.empty()) {
    pair<long long, long long> ele = *s.begin();
    long long wt = ele.first;
    long long pos = ele.second;
    s.erase(ele);
    if (vis[pos] == true) continue;
    vis[pos] = true;
    cnt++;
    if (cnt == k + 1) break;
    for (auto j : v[pos]) {
      if (d[j.first] > d[pos] + j.second) {
        parent[j.first] = pos;
        d[j.first] = d[pos] + j.second;
        s.insert(make_pair(d[j.first], j.first));
      }
    }
  }
  vector<long long> ans;
  for (long long i = 2; i <= n; i++) {
    if (vis[i] == true) {
      ans.push_back(mapp[make_pair(i, parent[i])]);
    }
  }
  cout << ans.size() << endl;
  ;
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
