#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long>>> v1[300050];
bool visited[300050];
int main() {
  long long n, m, ok;
  cin >> n >> m >> ok;
  for (long long i = 1; i <= m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    v1[x].push_back(make_pair(y, make_pair(w, i)));
    v1[y].push_back(make_pair(x, make_pair(w, i)));
  }
  priority_queue<pair<long long, long long>> q;
  vector<long long> d(n + 1, (long long)10e18);
  d[1] = 0;
  q.push(make_pair(1, 1));
  vector<long long> last(n + 1, -1);
  long long temp = 0;
  vector<long long> ans;
  while (!q.empty() && temp < ok) {
    auto z = q.top();
    q.pop();
    long long k = z.second;
    if (visited[k]) {
      continue;
    }
    visited[k] = true;
    if (last[k] != -1) {
      temp++;
      ans.push_back(last[k]);
    }
    for (auto y : v1[k]) {
      long long to = y.first;
      long long w = y.second.first;
      long long idx = y.second.second;
      if (visited[to]) {
        continue;
      }
      if (d[to] > d[k] + w) {
        d[to] = d[k] + w;
        last[to] = idx;
        q.push(make_pair(-d[to], to));
      }
    }
  }
  std::cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) {
    std::cout << ans[i] << endl;
  }
}
