#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pli = pair<ll, int>;
const int N = 300005;
const ll inf = ll(1e18);
struct E {
  int first;
  ll c;
  int i;
};
int n, m, k, v[N];
ll d[N];
vector<E> e[N];
vector<int> r;
priority_queue<pli, vector<pli>, greater<pli>> pq;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int first, second;
    ll z;
    scanf("%d%d%lld", &first, &second, &z);
    e[first].push_back({second, z, i});
    e[second].push_back({first, z, i});
  }
  fill(d + 2, d + n + 1, inf);
  pq.push({0, 1});
  while (!pq.empty()) {
    int cx = pq.top().second;
    ll cd = pq.top().first;
    pq.pop();
    if (cd > d[cx]) continue;
    if (v[cx]) r.push_back(v[cx]);
    for (E i : e[cx]) {
      if (cd + i.c < d[i.first]) {
        d[i.first] = cd + i.c;
        v[i.first] = i.i;
        pq.push({d[i.first], i.first});
      }
    }
  }
  printf("%d\n", min(k, int(r.size())));
  for (int i = 0; i < min(k, int(r.size())); i++) printf("%d ", r[i]);
}
