#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<vector<pair<long long, long long> > > g;
void fun() {
  cin >> n >> m >> k;
  g.resize(n);
  map<pair<int, int>, int> index;
  for (long long i = 0; i < m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back({y, z});
    g[y].push_back({x, z});
    index[{x, y}] = i + 1;
    index[{y, x}] = i + 1;
  }
  vector<long long> dis(n, LLONG_MAX), par(n);
  dis[0] = 0;
  set<pair<long long, long long> > s;
  s.insert({0, 0});
  while (!s.empty()) {
    pair<long long, long long> d = *s.begin();
    s.erase(s.begin());
    for (auto j : g[d.second]) {
      if (dis[j.first] > dis[d.second] + j.second) {
        s.erase({dis[j.first], j.first});
        dis[j.first] = dis[d.second] + j.second;
        par[j.first] = d.second;
        s.insert({dis[j.first], j.first});
      }
    }
  }
  vector<pair<long long, int> > dissort;
  for (int i = 0; i < n; i++) dissort.push_back({dis[i], i});
  sort((dissort).begin(), (dissort).end());
  cout << min(n - 1, k) << "\n";
  k = min(n - 1, k);
  int j = 1;
  while (k--) {
    int x = dissort[j].second;
    cout << index[{x, par[x]}] << " ";
    j++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  ;
  int t = 1;
  while (t--) fun();
}
