#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<long long, int> > > g[303030];
vector<int> gg[303030];
int used[303030];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back({b, {c, i + 1}});
    g[b].push_back({a, {c, i + 1}});
  }
  int u = 1;
  priority_queue<pair<pair<long long, long long>, pair<int, int> > > dij;
  dij.push({{0, 0}, {u, 0}});
  long long v = 0;
  vector<int> vv;
  while (!dij.empty()) {
    auto x = dij.top();
    dij.pop();
    if (used[x.second.first]) continue;
    used[x.second.first] = 1;
    if (x.second.second > 0) vv.push_back(x.second.second);
    v += -x.first.second;
    for (auto nx : g[x.second.first]) {
      dij.push({{x.first.first - nx.second.first, -nx.second.first},
                {nx.first, nx.second.second}});
    }
  }
  cout << min((long long)vv.size(), (long long)k) << endl;
  int cnt = 0;
  for (int vvv : vv) {
    if (cnt == k) break;
    cnt++;
    cout << vvv << " ";
  }
}
