#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 5;
const long long inf = 3e14;
long long n, m, k, to_remove = 0;
long long w[N];
long long arrival[N], departure[N], deg[N];
pair<long long, long long> parent[N];
vector<pair<long long, long long> > g[N], ng[N];
set<long long> ans;
vector<long long> v;
void dijkstra(long long source, long long destination, long long arrival[],
              long long departure[]) {
  for (long long i = 1; i <= n; i++) {
    arrival[i] = inf;
    departure[i] = inf;
  }
  arrival[source] = 0;
  set<pair<long long, long long> > s;
  s.insert({0, source});
  while (!s.empty()) {
    auto x = *(s.begin());
    s.erase(x);
    departure[x.second] = arrival[x.second];
    for (auto it : g[x.second]) {
      if (arrival[it.first] > departure[x.second] + w[it.second]) {
        s.erase({arrival[it.first], it.first});
        arrival[it.first] = departure[x.second] + w[it.second];
        s.insert({arrival[it.first], it.first});
        parent[it.first] = {x.second, it.second};
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    ans.insert(parent[i].second);
    deg[parent[i].first]++;
    ng[parent[i].first].push_back({i, parent[i].second});
  }
  long long extra = max(0LL, k - (n - 1));
  to_remove = max(0LL, n - 1 - k);
  for (long long i = 1; i <= m; i++) {
    if (!extra) break;
    if (ans.find(i) == ans.end()) {
      ans.insert(i);
      extra--;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  to_remove = m - k;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    cin >> u >> v >> w[i];
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  dijkstra(1, 1, arrival, departure);
  queue<long long> q;
  for (long long i = 2; i <= n; i++) {
    if (deg[i] == 0) q.push(i);
  }
  while (q.size() && to_remove > 0) {
    long long cur = q.front();
    q.pop();
    to_remove--;
    ans.erase(parent[cur].second);
    deg[parent[cur].first]--;
    if (parent[cur].first != 1 && deg[parent[cur].first] == 0)
      q.push(parent[cur].first);
  }
  cout << ans.size() << "\n";
  for (auto &it : ans) cout << it << " ";
  return 0;
}
