#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int t, v, next;
  Edge() {}
  Edge(int a, int b, int c) : t(a), v(b), next(c) {}
};
Edge e[600005];
int head[300005];
long long dis[300005];
int p[300005];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
void dijkstra(int k) {
  memset(dis, 0x3f, sizeof(dis));
  dis[1] = 0;
  q.push(pair<long long, int>(0, 1));
  int cnt = 0;
  while (!q.empty()) {
    pair<long long, int> t = q.top();
    q.pop();
    if (dis[t.second] < t.first) continue;
    int a = t.second;
    long long b = t.first;
    if (p[a] && cnt < k) {
      printf("%d ", p[a]);
      cnt++;
    }
    for (int i = head[a]; i; i = e[i].next)
      if (b + e[i].v < dis[e[i].t]) {
        int u = e[i].t;
        dis[u] = b + e[i].v;
        p[u] = ((i + 1) >> 1);
        q.push(pair<long long, int>(dis[u], u));
      }
  }
  printf("\n");
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  k = min(k, n - 1);
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    e[2 * i - 1] = Edge(y, z, head[x]);
    head[x] = 2 * i - 1;
    e[2 * i] = Edge(x, z, head[y]);
    head[y] = 2 * i;
  }
  printf("%d\n", k);
  dijkstra(k);
  return 0;
}
