#include <bits/stdc++.h>
using namespace std;
int N, M, k;
int tot, ver[300005 << 1], head[300005], edge[300005 << 1], Next[300005 << 1];
long long dis[300005];
struct Heap_Data {
  int Nod;
  long long Dis;
} Heap[300005];
int Cnt, Sz;
bool inq[300005];
int Que[300005], Edge[300005];
template <typename Rogue>
void Read(Rogue &x) {
  x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
}
template <typename Rogue>
void write(Rogue x) {
  if (x >= 10) write(x / 10);
  putchar((char)(x % 10 + '0'));
}
template <typename Rogue>
void writeln(Rogue x) {
  write(x);
  puts("");
}
inline void addedge(int u, int v, int w) {
  ++tot;
  ver[tot] = v;
  edge[tot] = w;
  Next[tot] = head[u];
  head[u] = tot;
}
inline void Get() {
  swap(Heap[Cnt], Heap[1]);
  --Cnt;
  int Index = 1;
  while ((Index << 1) <= Cnt) {
    if ((Index << 1 | 1) <= Cnt &&
        Heap[Index << 1 | 1].Dis < Heap[Index << 1].Dis) {
      if (Heap[Index << 1 | 1].Dis < Heap[Index].Dis) {
        swap(Heap[Index << 1 | 1], Heap[Index]);
        Index = (Index << 1 | 1);
      } else
        break;
    } else {
      if (Heap[Index << 1].Dis < Heap[Index].Dis) {
        swap(Heap[Index << 1], Heap[Index]);
        Index = (Index << 1);
      } else
        break;
    }
  }
}
inline void Push(int Node, long long Dist) {
  ++Cnt;
  Heap[Cnt].Dis = Dist;
  Heap[Cnt].Nod = Node;
  int Index = Cnt;
  while (Index >= 2) {
    if (Heap[Index].Dis < Heap[Index >> 1].Dis) {
      swap(Heap[Index], Heap[Index >> 1]);
      Index = (Index >> 1);
    } else
      break;
  }
}
inline void dijkstra() {
  for (int i = 1; i <= N; i++) dis[i] = 10000000000000000;
  dis[1] = 0;
  Cnt = 1;
  Heap_Data x;
  Heap[1].Nod = 1;
  Heap[1].Dis = 0;
  while (Cnt) {
    x = Heap[1];
    Get();
    if (inq[x.Nod]) continue;
    inq[x.Nod] = 1;
    for (int i = head[x.Nod]; i; i = Next[i])
      if (dis[ver[i]] > dis[x.Nod] + edge[i]) {
        dis[ver[i]] = dis[x.Nod] + edge[i];
        Push(ver[i], dis[ver[i]]);
      }
  }
}
void Bfs() {
  int h, t;
  h = t = 1;
  Que[1] = 1;
  while (h <= t) {
    int Qh = Que[h];
    ++h;
    for (int i = head[Qh]; i; i = Next[i])
      if (!inq[ver[i]] && dis[ver[i]] == dis[Qh] + edge[i]) {
        if (Sz <= k) {
          Edge[Sz] = (i + 1) / 2;
          ++Sz;
        } else
          return;
        inq[ver[i]] = 1;
        ++t;
        Que[t] = ver[i];
      }
  }
}
int main() {
  Read(N);
  Read(M);
  Read(k);
  if (k == 0) {
    puts("0");
    return 0;
  }
  int u, v, w;
  tot = 0;
  memset(head, 0, sizeof head);
  for (int i = 1; i <= M; i++) {
    Read(u);
    Read(v);
    Read(w);
    addedge(u, v, w);
    addedge(v, u, w);
  }
  memset(inq, 0, sizeof inq);
  dijkstra();
  memset(inq, 0, sizeof inq);
  Sz = 1;
  Bfs();
  --Sz;
  writeln(Sz);
  write(Edge[1]);
  for (int i = 2; i <= Sz; ++i) putchar(' '), write(Edge[i]);
  puts("");
  return 0;
}
