#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e15;
const int MN = 300010;
int from[MN], to[MN], weight[MN];
int depth[MN];
vector<int> g[MN];
bool cmp(int i, int j) { return depth[i] < depth[j]; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> from[i] >> to[i] >> weight[i];
    from[i]--;
    to[i]--;
    g[from[i]].push_back(i);
    g[to[i]].push_back(i);
  }
  memset(depth, -1, sizeof depth);
  priority_queue<tuple<long long, int, int>,
                 vector<tuple<long long, int, int> >,
                 greater<tuple<long long, int, int> > >
      pq;
  pq.push(tuple<long long, int, int>(0, 0, -1));
  vector<long long> dist(n, oo);
  dist[0] = 0;
  vector<int> ans;
  while (!pq.empty() && (int)ans.size() < k) {
    long long d;
    int u, id;
    tie(d, u, id) = pq.top();
    pq.pop();
    if (d > dist[u]) continue;
    if (id != -1) ans.push_back(id);
    for (int e : g[u]) {
      int v = from[e] + to[e] - u;
      if (dist[u] + weight[e] < dist[v]) {
        dist[v] = dist[u] + weight[e];
        pq.push(tuple<long long, int, int>(dist[v], v, e));
      }
    }
  }
  cout << (int)ans.size() << '\n';
  for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] + 1 << " ";
  cout << '\n';
  return 0;
}
