#include <bits/stdc++.h>
using namespace std;
vector<int> s[300001];
long long dis[300001];
int n, m, k, cnt, sum, x[300001], used[300001], y[300001], in[300001],
    out[300001], z[300001], pre[600001], nxt[600001], h[300001], v[600001],
    op[600001];
struct oo {
  int id;
  long long dis;
};
bool vis[300001];
bool operator<(oo a, oo b) { return a.dis > b.dis; }
priority_queue<oo> q;
void add(int x, int y, int z, int now) {
  pre[++cnt] = y, nxt[cnt] = h[x];
  h[x] = cnt, v[cnt] = z;
  op[cnt] = now;
  pre[++cnt] = x, nxt[cnt] = h[y];
  h[y] = cnt, v[cnt] = z;
  op[cnt] = now;
}
void ins(int x, int y, int z, int now) {
  pre[++cnt] = y, nxt[cnt] = h[x];
  h[x] = cnt, v[cnt] = z;
  op[cnt] = now;
}
void dijkstra() {
  memset(dis, 63, sizeof dis);
  q.push((oo){1, dis[1] = 0});
  while (!q.empty()) {
    int x = q.top().id;
    q.pop();
    if (vis[x]) continue;
    vis[x] = 1;
    for (int i = h[x]; i; i = nxt[i])
      if (dis[pre[i]] > dis[x] + v[i])
        dis[pre[i]] = dis[x] + v[i], q.push((oo){pre[i], dis[pre[i]]});
  }
}
bool cmp(vector<int> a, vector<int> b) { return a.size() > b.size(); }
void topsort() {
  queue<int> q;
  for (int i = 1; i <= n; i++)
    if (!in[i]) q.push(i);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = h[x]; i; i = nxt[i]) {
      used[op[i]] = 0, sum--;
      if (sum <= k) return;
      if (!(--in[pre[i]])) q.push(pre[i]);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (register int i = 1; i <= m; i++)
    scanf("%d%d%d", &x[i], &y[i], &z[i]), add(x[i], y[i], z[i], i);
  dijkstra();
  for (int i = 1; i <= n; i++)
    for (int j = h[i]; j; j = nxt[j])
      if (dis[pre[j]] == dis[i] + v[j]) used[op[j]] = i;
  memset(h, 0, sizeof h), cnt = 0;
  for (int i = 1; i <= m; i++)
    if (used[i]) {
      sum++;
      if (used[i] == x[i])
        s[y[i]].push_back(i), in[y[i]]++, out[x[i]]++;
      else
        s[x[i]].push_back(i), in[x[i]]++, out[y[i]]++;
    }
  if (sum <= k) {
    printf("%d\n", sum);
    for (int i = 1; i <= m; i++)
      if (used[i]) printf("%d ", i);
    return 0;
  }
  int now = 1;
  while (now <= n) {
    if (s[now].size() > 1) {
      int w = s[now].size(), t;
      if (w - 1 >= sum - k)
        t = sum - k;
      else
        t = w - 1;
      sum -= t;
      for (int i = 0; i < t; i++) used[s[now][i]] = 0;
      if (sum <= k) break;
    }
    if (sum <= k) break;
    now++;
  }
  if (sum <= k) {
    printf("%d\n", sum);
    for (int i = 1; i <= m; i++)
      if (used[i]) printf("%d ", i);
    return 0;
  }
  memset(in, 0, sizeof in), sum = cnt = 0, memset(h, 0, sizeof h);
  for (int i = 1; i <= m; i++)
    if (used[i]) {
      sum++;
      if (used[i] == x[i])
        ins(y[i], x[i], z[i], i), in[x[i]]++;
      else
        ins(x[i], y[i], z[i], i), in[y[i]]++;
    }
  topsort();
  printf("%d\n", sum);
  for (int i = 1; i <= m; i++)
    if (used[i]) printf("%d ", i);
}
