#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 5;
const int N = 3e5 + 10;
int n, m, k;
struct Node {
  int w, id, v;
} node[N];
long long dist[N];
bool vis[N];
vector<Node> G[N];
void dfs(int u) {
  vis[u] = 1;
  for (auto x : G[u]) {
    int v = x.v, id = x.id, w = x.w;
    if (!vis[v] && dist[v] == dist[u] + w) {
      if (!k) return;
      printf("%d ", id);
      k--;
      dfs(v);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) dist[i] = inf;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    G[u].push_back({w, i, v});
    G[v].push_back({w, i, u});
  }
  priority_queue<pair<long long, int>> q;
  q.push({0, 1});
  dist[1] = 0;
  while (!q.empty()) {
    auto now = q.top();
    q.pop();
    int u = now.second;
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto x : G[u]) {
      if (!vis[x.v]) {
        int v = x.v, w = x.w;
        if (dist[v] > dist[u] + w) {
          dist[v] = dist[u] + w;
          q.push({-dist[v], v});
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) vis[i] = 0;
  printf("%d\n", min(n - 1, k));
  dfs(1);
  return 0;
}
