#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 7;
const int maxm = 6e5 + 7;
const long long inf = 0x3f3f3f3f3f3f3f3f;
struct edge {
  int to, next;
  long long w;
} e[maxm];
struct node {
  int id, cntt;
  long long v;
  bool operator<(const node &t) const {
    if (v != t.v) return v > t.v;
  }
};
struct node2 {
  long long len;
  int id;
  bool operator<(const node2 &t) const {
    if (len != t.len) return len > t.len;
  }
} eg[maxm];
int n, m, k, head[maxm], vis[maxm], cnt, fa[maxm], tot, ans[maxm];
long long we[maxm], dis[maxm];
priority_queue<node> q;
void add(int u, int v, long long w) {
  e[cnt].next = head[u];
  e[cnt].to = v;
  e[cnt].w = w;
  head[u] = cnt++;
}
void dij(int s) {
  for (int i = 1; i <= n; i++) dis[i] = inf, vis[i] = 0, we[i] = 1ll;
  for (int i = 0; i < m; i++) eg[i].id = i + 1;
  dis[s] = 0;
  while (!q.empty()) q.pop();
  q.push(node{s, 0, 0ll});
  while (!q.empty()) {
    node p = q.top();
    q.pop();
    if (vis[p.id]) continue;
    vis[p.id] = 1;
    if (p.id != 1) ans[++tot] = p.cntt;
    for (int i = head[p.id]; ~i; i = e[i].next) {
      int v = e[i].to;
      long long w = e[i].w;
      if (!vis[v] && dis[v] > dis[p.id] + w) {
        dis[v] = dis[p.id] + w;
        fa[v] = p.id;
        q.push(node{v, i / 2 + 1, dis[v]});
      }
    }
  }
}
void solve() {
  memset(head, -1, sizeof(head));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    add(u, v, w);
    add(v, u, w);
  }
  dij(1);
  k = min(tot, k);
  printf("%d\n", k);
  for (int i = 1; i <= k; i++) {
    printf("%d ", ans[i]);
  }
}
int main(void) {
  solve();
  return 0;
}
