#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tiii = tuple<int, int, int>;
using tlll = tuple<ll, ll, ll>;
vector<tiii> gr[300001];
ll inf = 1000000000000000ll;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    gr[u].emplace_back(tiii(v, w, i));
    gr[v].emplace_back(tiii(u, w, i));
  }
  priority_queue<pll> q;
  vector<ll> dist(n, inf);
  dist[0] = 0;
  q.emplace(pll(0, 0));
  vector<int> par(n, -1);
  int c = 0;
  queue<int> aq;
  while (q.size() && c < k) {
    ll negd = q.top().first;
    ll d = -negd;
    int u = q.top().second;
    q.pop();
    if (d > dist[u]) continue;
    if (par[u] != -1) {
      c++;
      aq.emplace(par[u]);
    }
    for (tiii x : gr[u]) {
      int v = get<0>(x);
      int w = get<1>(x);
      int idx = get<2>(x);
      if (dist[v] > dist[u] + w) {
        dist[v] = dist[u] + w;
        par[v] = idx;
        q.emplace(pll(-dist[v], v));
      }
    }
  }
  cout << aq.size() << '\n';
  while (aq.size()) {
    cout << aq.front() + 1 << ' ';
    aq.pop();
  }
  return 0;
}
