#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
const int MAXN = 3 * 1e5 + 5;
vector<vector<pair<int, int>>> adj(MAXN);
vector<long long int> dist(MAXN, (long long int)(1e18));
vector<long long int> par(MAXN);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<long long int> w(m + 1);
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u >> w[i];
    adj[v].push_back({u, i});
    adj[u].push_back({v, i});
  }
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  dist[1] = 0;
  pq.push({0, 1});
  int cnt = 0;
  vector<long long int> ans;
  while (!pq.empty()) {
    int v = pq.top().second;
    long long int d = pq.top().first;
    if (d != dist[v]) {
      pq.pop();
      continue;
    }
    if (v != 1) {
      ans.push_back(par[v]);
      cnt++;
    }
    pq.pop();
    for (auto x : adj[v]) {
      if (dist[x.first] > dist[v] + w[x.second]) {
        dist[x.first] = dist[v] + w[x.second];
        pq.push({dist[x.first], x.first});
        par[x.first] = x.second + 1;
      }
    }
    if (cnt == k) break;
  }
  cout << (int)(ans.size()) << '\n';
  for (auto x : ans) cout << x << " ";
}
