#include <bits/stdc++.h>
using namespace std;
const int LIM = 3e5 + 10;
const long long INF = 0xfffffffffffffff;
vector<pair<int, pair<long long, int>>> adj[LIM];
long long dist[LIM];
int from[LIM];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k, u, v;
  long long w;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v >> w;
    adj[u].push_back(make_pair(v, make_pair(w, i)));
    adj[v].push_back(make_pair(u, make_pair(w, i)));
  }
  memset(from, -1, sizeof from);
  for (int i = 1; i <= n; i++) dist[i] = INF;
  set<pair<long long, int>> newnode;
  pair<long long, int> crt = make_pair(0, 1);
  newnode.insert(crt);
  dist[1] = 0;
  int cnt = 0;
  vector<int> ans;
  while (!newnode.empty() && ans.size() < k) {
    crt = *newnode.begin();
    newnode.erase(newnode.begin());
    int id = crt.second;
    if (from[id] > 0) ans.push_back(from[id]);
    for (int i = 0; i < adj[id].size(); i++) {
      long long weight = adj[id][i].second.first;
      int to = adj[id][i].first;
      if (dist[id] + weight < dist[to]) {
        newnode.erase(make_pair(dist[to], to));
        dist[to] = dist[id] + weight;
        from[to] = adj[id][i].second.second;
        newnode.insert(make_pair(dist[to], to));
      }
    }
  }
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << ' ';
    cout << ans[i];
  }
  cout << "\n";
  return 0;
}
