#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
using namespace std;
vector<pair<pair<long long, long long>, long long> > adj[300005];
vector<pair<long long, long long> > edge[300005];
long long visited[300005], dist[300005];
long long pos[300005];
map<long long, long long> mpp;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  long long i, j;
  for (i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    adj[u].push_back(make_pair(make_pair(v, w), i));
    adj[v].push_back(make_pair(make_pair(u, w), i));
    edge[i].push_back(make_pair(u, v));
  }
  vector<pair<long long, long long> > ans;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(make_pair(0, 1));
  for (i = 2; i <= n; i++) dist[i] = 1e18;
  dist[1] = 0;
  visited[1] = 1;
  while (!pq.empty()) {
    pair<long long, long long> u = pq.top();
    pq.pop();
    if (dist[u.second] < u.first) continue;
    long long i;
    for (i = 0; i < adj[u.second].size(); i++) {
      long long x = adj[u.second][i].first.first;
      long long w = adj[u.second][i].first.second;
      long long ind = adj[u.second][i].second;
      if (dist[x] > dist[u.second] + w) {
        dist[x] = dist[u.second] + w;
        pq.push(make_pair(dist[x], x));
        mpp[pos[x]]--;
        pos[x] = ind;
        mpp[pos[x]] += 1;
        ans.push_back(make_pair(dist[x], ind));
      }
    }
  }
  sort((ans).begin(), (ans).end());
  vector<long long> ans1;
  long long c = 0;
  i = 0;
  while (c < k && i < ans.size()) {
    if (ans[i].second && mpp[ans[i].second] > 0) {
      ans1.push_back(ans[i].second);
      c++;
    }
    i++;
  }
  cout << c << "\n";
  for (i = 0; i < ans1.size(); i++) cout << ans1[i] << " ";
  return 0;
}
