#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MAXN = 300007;
vector<long long> eid[MAXN];
vector<long long> edg[MAXN];
vector<long long> cst[MAXN];
long long dst[MAXN];
long long pid[MAXN];
long long vs[MAXN];
long long rnk[MAXN];
void dijkstra(long long n, long long s) {
  for (long long i = 1; i <= n; i++) dst[i] = INF;
  dst[s] = 0;
  priority_queue<pair<long long, long long> > pq;
  pq.push(pair<long long, long long>(0, s));
  vector<long long> used;
  while (!pq.empty()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    long long u = p.second;
    long long c = -p.first;
    if (vs[u]) continue;
    vs[u] = 1;
    used.push_back(pid[u]);
    for (long long i = 0; i < edg[u].size(); i++) {
      long long v = edg[u][i];
      long long newc = c + cst[u][i];
      long long id = eid[u][i];
      if (vs[v]) continue;
      if (newc < dst[v]) {
        dst[v] = newc;
        pid[v] = id;
        pq.push(pair<long long, long long>(-newc, v));
      }
    }
  }
  for (long long i = 0; i < used.size(); i++) {
    rnk[used[i]] = i;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    edg[u].push_back(v);
    cst[u].push_back(c);
    eid[u].push_back(i);
    edg[v].push_back(u);
    cst[v].push_back(c);
    eid[v].push_back(i);
    rnk[i] = MAXN;
  }
  dijkstra(n, 1);
  vector<pair<long long, long long> > vp;
  for (long long i = 1; i <= m; i++) {
    vp.push_back(pair<long long, long long>(rnk[i], i));
  }
  sort(vp.begin(), vp.end());
  cout << k << endl;
  for (long long i = 0; i < k; i++) {
    cout << vp[i].second << " ";
  }
  return 0;
}
