#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};
const int drx[] = {2, 2, 1, 1, -1, -1, -2, -2};
const int dry[] = {1, -1, 2, -2, 2, -2, 1, -1};
const int N = 400500;
int n, m, k, x, y, w, cnt;
vector<pair<int, pair<int, int> > > g[N];
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y >> w;
    x--;
    y--;
    g[x].push_back(make_pair(y, make_pair(w, i)));
    g[y].push_back(make_pair(x, make_pair(w, i)));
  }
  vector<long long> d(n, 1000000000000000000LL);
  set<pair<long long, int> > s;
  vector<int> lastv(n, -1);
  d[0] = 0;
  s.insert({0, 0});
  while (!s.empty() && cnt < k) {
    int v = s.begin()->second;
    cerr << v << endl;
    s.erase(s.begin());
    if (lastv[v] != -1) {
      ans.push_back(lastv[v]);
      cnt++;
    }
    for (auto i : g[v]) {
      int to = i.first;
      int w = i.second.first;
      int id = i.second.second;
      if (d[to] > d[v] + w) {
        s.erase({d[to], to});
        d[to] = d[v] + w;
        s.insert({d[to], to});
        lastv[to] = id;
      }
    }
  }
  cout << (int((ans).size())) << endl;
  for (auto i : ans) cout << i << " ";
  return 0;
}
