#include <bits/stdc++.h>
using namespace std;
const int N = 1011322;
const int M = 230;
const long long MOD = 998244353LL;
const double pi = acos(-1.0);
inline int lowbit(int x) { return x & (-x); }
void print(long long x) {
  if (x > 9) print(x / 10);
  printf("%c", '0' + x % 10);
}
long long pow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return r;
}
long long PowMod(long long a, long long b, long long P) {
  long long r = 1;
  while (b) {
    if (b & 1) r = r * a % P;
    a = a * a % P, b >>= 1;
  }
  return r;
}
void gcd(long long a, long long b, long long &d, long long &x, long long &y) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    gcd(b, a % b, d, y, x);
    y -= x * (a / b);
  }
}
inline long long inv(long long a, long long n) {
  long long d, x, y;
  gcd(a, n, d, x, y);
  return d == 1 ? (x + n) % n : -1;
}
int gcd(int x, int y) {
  if (!y) return x;
  return gcd(y, x % y);
}
struct node {
  long long d;
  int u;
};
inline bool operator<(const node &x, const node &y) { return x.d > y.d; }
int n, m, k, headp[N], nextp[N], to[N], from[N], p[N], a[N][3];
long long bin[N], d[N], v[N];
bool done[N], ans[N];
priority_queue<node> Q;
inline void addedge(int x, int y, long long z, int &tot) {
  from[tot] = x;
  to[tot] = y;
  v[tot] = z;
  nextp[tot] = headp[x];
  headp[x] = tot;
  ++tot;
}
int dfs(int x, int k) {
  --k;
  d[x] = 1;
  if (!k) return 0;
  for (int i = headp[x]; i != -1; i = nextp[i]) {
    int y = to[i];
    if (d[y]) continue;
    done[i] = true;
    k = dfs(y, k);
    if (!k) return k;
  }
  return k;
}
int main() {
  int cases = 1;
  for (int iii = 1; iii <= cases; ++iii) {
    scanf("%d%d%d", &n, &m, &k);
    int tot = 0;
    memset(headp, -1, sizeof(headp));
    for (int i = 0; i < m; ++i) {
      int x, y;
      long long z;
      scanf("%d%d%I64d", &x, &y, &z);
      addedge(x, y, z, tot);
      addedge(y, x, z, tot);
    }
    for (int i = 2; i <= n; ++i) d[i] = 1e18;
    d[1] = 0;
    Q.push(node({0, 1}));
    while (!Q.empty()) {
      node tempnode = Q.top();
      Q.pop();
      int u = tempnode.u;
      if (done[u]) continue;
      done[u] = true;
      for (int i = headp[u]; i != -1; i = nextp[i]) {
        int y = to[i];
        if (d[y] > d[u] + v[i]) {
          d[y] = d[u] + v[i];
          Q.push(node({d[y], y}));
        }
      }
    }
    int mm = 0;
    for (int i = 0; i < tot; ++i) {
      if (d[from[i]] + v[i] == d[to[i]]) a[mm][0] = from[i];
      a[mm][1] = to[i];
      a[mm][2] = (i >> 1) + 1;
      ++mm;
    }
    memset(headp, -1, sizeof(headp));
    tot = 0;
    for (int i = 0; i < mm; ++i) addedge(a[i][0], a[i][1], 1, tot);
    memset(done, 0, sizeof(done));
    memset(d, 0, sizeof(d));
    dfs(1, min(k + 1, n));
    k = min(k, n - 1);
    printf("%d\n", k);
    for (int i = 0; i < tot; ++i)
      if (done[i]) printf("%d ", a[i][2]);
    puts("");
  }
}
