#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long> > > g[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    --x;
    --y;
    g[x].push_back({y, {w, i}});
    g[y].push_back({x, {w, i}});
  }
  set<pair<long long, long long> > q;
  vector<long long> d(n, 1000000000000000000);
  d[0] = 0;
  q.insert({0, 0});
  vector<long long> vis(n, -1);
  vector<long long> res;
  long long c = 0;
  while (!q.empty() and c < k) {
    auto z = *q.begin();
    q.erase(q.begin());
    long long p = z.second;
    if (vis[p] != -1) {
      c++;
      res.push_back(vis[p]);
    }
    for (auto x : g[p]) {
      long long t = x.first;
      long long w = x.second.first;
      long long i = x.second.second;
      if (d[t] > d[p] + w) {
        q.erase({d[t], t});
        d[t] = d[p] + w;
        vis[t] = i;
        q.insert({d[t], t});
      }
    }
  }
  cout << res.size() << "\n";
  for (auto x : res) {
    cout << ++x << " ";
  }
  cout << "\n";
}
