#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long int, int>, int>> adj[300010];
vector<pair<int, int>> last[300010];
pair<int, int> P[300010];
bool edge[300010];
void dijkstra(int n) {
  priority_queue<pair<pair<long long int, int>, int>> q;
  q.push(make_pair(make_pair(0, 1), -1));
  bool marked[n + 1];
  long long int val[n + 1];
  for (int i = 1; i <= n; i++) {
    marked[i] = false;
    val[i] = 1e16;
  }
  val[1] = 0;
  while (!q.empty()) {
    pair<pair<long long int, int>, int> T = q.top();
    q.pop();
    if (marked[T.first.second]) {
      continue;
    }
    marked[T.first.second] = true;
    if (T.second != -1) {
      int x = T.second;
      last[P[x].first].push_back(make_pair(P[x].second, x));
      last[P[x].second].push_back(make_pair(P[x].first, x));
      edge[x] = true;
    }
    int u = T.first.second;
    for (pair<pair<long long int, int>, int> it : adj[u]) {
      int v = it.first.second;
      long long int w = it.first.first;
      int idx = it.second;
      if (marked[v] || val[u] + w > val[v]) {
        continue;
      }
      val[v] = val[u] + w;
      q.push(make_pair(make_pair(-val[v], v), idx));
    }
  }
  return;
}
int K;
void dfs(int cur, int prev) {
  for (auto &it : last[cur]) {
    if (it.first == prev) {
      continue;
    }
    if (K == 0) {
      return;
    }
    printf("%d ", it.second + 1);
    K--;
    dfs(it.first, cur);
  }
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    int x, y;
    long long int w;
    scanf("%d %d %lld", &x, &y, &w);
    adj[x].push_back(make_pair(make_pair(w, y), i));
    adj[y].push_back(make_pair(make_pair(w, x), i));
    P[i] = make_pair(x, y);
    edge[i] = false;
  }
  dijkstra(n);
  if (k >= n - 1) {
    printf("%d\n", n - 1);
    for (int i = 0; i < m; i++) {
      if (edge[i]) {
        printf("%d ", i + 1);
      }
    }
  } else {
    printf("%d\n", k);
    K = k;
    dfs(1, -1);
  }
  return 0;
}
