#include <bits/stdc++.h>
using namespace std;
int n, m, k, viz[300005], gr[300005], viz2[300005];
long long dist[300005];
priority_queue<pair<long long, pair<int, int> >,
               vector<pair<long long, pair<int, int> > >,
               greater<pair<long long, pair<int, int> > > >
    q;
vector<pair<long long, pair<int, int> > > v[300005];
queue<pair<int, pair<int, int> > > q2;
struct ceva {
  int nod, ind;
} pred[300005];
int main() {
  int i, x, y, nod, vec, muchie, ans = 0;
  long long ct, cost;
  cin >> n >> m >> k;
  for (i = 1; i <= m; i++) {
    cin >> x >> y >> ct;
    v[x].push_back({ct, {y, i}});
    v[y].push_back({ct, {x, i}});
  }
  for (i = 2; i <= n; i++) dist[i] = 1e16;
  q.push({0, {1, 0}});
  while (!q.empty()) {
    nod = q.top().second.first;
    ct = q.top().first;
    q.pop();
    viz[nod] = 1;
    if (dist[nod] == ct)
      for (auto it = v[nod].begin(); it != v[nod].end(); ++it)
        if (!viz[(*it).second.first]) {
          vec = (*it).second.first;
          muchie = (*it).second.second;
          cost = (*it).first;
          if (dist[vec] > dist[nod] + cost) {
            dist[vec] = dist[nod] + cost;
            pred[vec].nod = nod;
            pred[vec].ind = muchie;
            q.push({dist[vec], {vec, muchie}});
          }
        }
  }
  for (i = 2; i <= n; i++) gr[pred[i].nod]++;
  for (i = 2; i <= n; i++)
    if (!gr[i]) q2.push({i, {pred[i].ind, pred[i].nod}});
  int nr = n - 1;
  while (nr > k) {
    nod = q2.front().first;
    muchie = q2.front().second.first;
    vec = q2.front().second.second;
    q2.pop();
    nr--;
    viz2[muchie] = 1;
    gr[vec]--;
    if (gr[vec] == 0) q2.push({vec, {pred[vec].ind, pred[vec].nod}});
  }
  for (i = 2; i <= n; i++)
    if (!viz2[pred[i].ind]) ans++;
  cout << ans << "\n";
  for (i = 2; i <= n; i++)
    if (!viz2[pred[i].ind]) cout << pred[i].ind << ' ';
  return 0;
}
