#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost, id;
  edge() {}
  edge(long long a, long long b, long long c) { to = a, cost = b, id = c; }
};
long long n, m, k;
vector<edge> G[300005];
long long dist[300005];
bool used[300005];
vector<long long> ans;
void dijkstra(vector<edge> G[], long long S, long long dist[]) {
  for (int i = 1; i <= n; i++) dist[i] = 1e18;
  dist[S] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      Q;
  Q.push(make_pair(0, S));
  long long v, d;
  while (Q.size()) {
    d = Q.top().first;
    v = Q.top().second;
    Q.pop();
    if (dist[v] < d) continue;
    for (int i = 0; i < G[v].size(); i++) {
      if (dist[G[v][i].to] > d + G[v][i].cost) {
        dist[G[v][i].to] = d + G[v][i].cost;
        Q.push(make_pair(dist[G[v][i].to], G[v][i].to));
      }
    }
  }
}
void dfs(int v) {
  used[v] = true;
  for (auto e : G[v]) {
    long long u = e.to;
    if (used[u]) continue;
    if (dist[v] + e.cost != dist[u]) continue;
    if (ans.size() >= k) continue;
    ans.push_back(e.id);
    dfs(u);
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  long long u, v, w;
  for (long long(i) = (1); (i) <= (m); (i)++) {
    cin >> u >> v >> w;
    G[u].push_back(edge(v, w, i));
    G[v].push_back(edge(u, w, i));
  }
  dijkstra(G, 1, dist);
  k = min(k, n - 1);
  dfs(1);
  cout << ans.size() << endl;
  for (auto x : ans) cout << x << " ";
  cout << endl;
  return 0;
}
