#include <bits/stdc++.h>
using namespace std;
const long long nr = 6e5 + 500;
inline long long read() {
  long long ret = 0;
  long long x = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * x;
}
long long fir[nr];
long long item = 0;
struct edge {
  long long nxt, to, val;
} p[nr * 2];
void add(long long a, long long b, long long c) {
  ++item;
  p[item].val = c;
  p[item].to = b;
  p[item].nxt = fir[a];
  fir[a] = item;
}
struct node {
  long long id;
  long long val;
};
bool operator<(node A, node B) { return A.val > B.val; }
long long dis[nr];
bool mark[nr];
long long start;
long long pre[nr];
void DIJ() {
  memset(dis, 999999, sizeof(dis));
  memset(mark, 0, sizeof(mark));
  priority_queue<node> Q;
  Q.push((node){start, 0});
  dis[start] = 0;
  while (!Q.empty()) {
    long long now = Q.top().id;
    Q.pop();
    if (mark[now]) continue;
    mark[now] = 1;
    for (int tmp = fir[now]; tmp; tmp = p[tmp].nxt) {
      long long v = p[tmp].to;
      if (dis[now] + p[tmp].val < dis[v]) {
        pre[v] = tmp;
        dis[v] = p[tmp].val + dis[now];
        Q.push((node){v, dis[v]});
      } else {
        if (dis[now] + p[tmp].val == dis[v]) {
          long long kk = pre[v];
          if (p[kk].val > p[tmp].val) {
            pre[v] = tmp;
          }
        }
      }
    }
  }
}
long long n, m;
long long k;
long long di[nr];
long long cnt = 0;
void dfs(long long now, long long fat) {
  if (cnt == k) {
    return;
  }
  for (int tmp = fir[now]; tmp; tmp = p[tmp].nxt) {
    long long v = p[tmp].to;
    if (v == fat) continue;
    if (cnt == k) {
      return;
    }
    if (pre[v] == tmp) {
      cnt++;
      cout << (tmp + 1) / 2 << " ";
      dfs(v, now);
    }
  }
}
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= m; i++) {
    long long a, b, c;
    a = read();
    b = read();
    c = read();
    add(a, b, c);
    add(b, a, c);
  }
  start = 1;
  DIJ();
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    tot += p[pre[i]].val;
  }
  long long g = min(n - 1, k);
  cout << g << endl;
  for (int i = 1; i <= n; i++) {
    di[i] = (pre[i] + 1) / 2;
  }
  dfs(1, 0);
  return 0;
}
