#include <bits/stdc++.h>
using namespace std;
int n, m, num, head[300010], pre[300010], pree[300010], k, vis[300010],
    las[300010], f[300010];
long long dis[300010], Dis[300010];
struct node {
  int v, t, pre, o;
} e[300010 * 2];
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    q;
int init() {
  int x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
void Add(int from, int to, int dis, int bj) {
  num++;
  e[num].v = to;
  e[num].t = dis;
  e[num].o = bj;
  e[num].pre = head[from];
  head[from] = num;
}
void Dij() {
  for (int i = 1; i <= n; i++) dis[i] = 1e16;
  dis[1] = 0;
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    pair<long long, int> now = q.top();
    q.pop();
    if (dis[now.second] < now.first) continue;
    for (int i = head[now.second]; i; i = e[i].pre) {
      int v = e[i].v;
      if (dis[v] > dis[now.second] + e[i].t) {
        dis[v] = dis[now.second] + e[i].t;
        pre[v] = now.second;
        pree[v] = e[i].o;
        q.push(make_pair(dis[v], v));
      }
    }
  }
}
void dij() {
  for (int i = 1; i <= n; i++) Dis[i] = 1e16;
  Dis[1] = 0;
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    pair<long long, int> now = q.top();
    q.pop();
    if (Dis[now.second] < now.first) continue;
    for (int i = head[now.second]; i; i = e[i].pre) {
      int v = e[i].v;
      if (Dis[v] > Dis[now.second] + e[i].t) {
        Dis[v] = Dis[now.second] + e[i].t;
        if (Dis[v] == dis[v]) {
          las[now.second] = v;
          vis[e[i].o] = 1;
        }
        q.push(make_pair(Dis[v], v));
      }
    }
  }
}
void Dfs(int now, int from) {
  if (k == 0) return;
  for (int i = head[now]; i; i = e[i].pre) {
    int v = e[i].v;
    if (v == from) continue;
    printf("%d ", e[i].o);
    k--;
    if (k == 0) return;
    Dfs(v, now);
    if (k == 0) return;
  }
}
int main() {
  n = init();
  m = init();
  k = init();
  int u, v, t;
  for (int i = 1; i <= m; i++) {
    u = init();
    v = init();
    t = init();
    Add(u, v, t, i);
    Add(v, u, t, i);
  }
  Dij();
  dij();
  printf("%d\n", k);
  if (k >= n - 1) {
    k = m - k;
    for (int i = 1; i <= m; i++) {
      if (vis[i] == 0 && k)
        k--;
      else
        printf("%d ", i);
    }
  } else {
    num = 0;
    memset(head, 0, sizeof(head));
    for (int i = 2; i <= n; i++)
      if (las[i] == 0) {
        int pos = i;
        f[pos] = 1;
        while (pre[pos]) {
          Add(pre[pos], pos, 0, pree[pos]);
          pos = pre[pos];
          if (f[pos]) break;
          f[pos] = 1;
        }
      }
    Dfs(1, 0);
  }
  return 0;
}
