#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
int p[N];
bool inc[N], visited[N];
vector<pair<pair<int, int>, int>> g[N];
int cnt = 0;
int n, m, k;
void dfs(int u) {
  visited[u] = 1;
  for (auto it : g[u]) {
    int v = it.first.first, ind = it.second;
    if (visited[v] == 1) continue;
    if (inc[ind]) {
      cnt++;
      cout << ind << " ";
      if (cnt == k) exit(0);
      dfs(v);
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].push_back({{v, w}, i});
    g[v].push_back({{u, w}, i});
  }
  set<pair<long long, int>> ss;
  vector<long long> d(n + 1, (long long)1e17);
  d[1] = 0;
  ss.insert({0, 1});
  int cnt = 0;
  while (!ss.empty()) {
    int u = ss.begin()->second;
    ss.erase(ss.begin());
    for (auto it : g[u]) {
      int v = it.first.first, w = it.first.second, ind = it.second;
      if (d[v] > d[u] + w) {
        ss.erase({d[v], v});
        d[v] = d[u] + w;
        ss.insert({d[v], v});
        cnt++;
        p[v] = ind;
      }
    }
  }
  cout << min(n - 1, k) << endl;
  for (int i = 2; i <= n; i++) inc[p[i]] = 1;
  if (k) dfs(1);
  return 0;
}
