#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
long long qpow(long long x, long long y, long long MOD) {
  long long a = 1;
  while (y) {
    if (y & 1) a = a * x % MOD;
    x = x * x % MOD;
    y >>= 1;
  }
  return a;
}
int n, m, k, tot, cnt;
int hd[N], vis[N], ans[N];
long long dis[N];
struct edge {
  int to, nxt, id;
  long long w;
} E[N];
void add(int u, int v, long long w, int i) {
  E[tot] = {v, hd[u], i, w};
  hd[u] = tot++;
}
struct node {
  int v;
  long long d;
  bool operator<(const node& r) const { return d > r.d; }
};
void dij() {
  for (int i = int(1); i <= int(n); ++i) dis[i] = INF;
  dis[1] = 0;
  priority_queue<node> q;
  q.push({1, 0});
  while (!q.empty()) {
    node tp = q.top();
    q.pop();
    int u = tp.v, d = tp.d;
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i = hd[u]; i != -1; i = E[i].nxt) {
      int v = E[i].to, w = E[i].w;
      if (dis[v] > dis[u] + w && !vis[v]) {
        dis[v] = dis[u] + w;
        q.push({v, dis[v]});
      }
    }
  }
}
void bfs() {
  memset(vis, 0, sizeof(vis));
  queue<int> q;
  vis[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = hd[u]; i != -1; i = E[i].nxt) {
      int v = E[i].to, w = E[i].w;
      if (dis[v] == dis[u] + w && !vis[v]) {
        if (cnt >= k) return;
        ans[++cnt] = E[i].id;
        vis[v] = 1;
        q.push(v);
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  memset(hd, -1, sizeof(hd));
  for (int i = int(1); i <= int(m); ++i) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    add(u, v, w, i);
    add(v, u, w, i);
  }
  dij();
  bfs();
  printf("%d\n", cnt);
  for (int i = int(1); i <= int(cnt); ++i) printf("%d ", ans[i]);
  return 0;
}
