#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int mod = 1e9 + 7, maxn = 3e5 + 100;
const long long INF = 1e18;
const double eps = 1e-8, PI = acos(-1);
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do x = x * 10 + ch - '0', ch = getchar();
  while (ch <= '9' && ch >= '0');
  x *= f;
}
int n, m, k;
struct node {
  int u;
  long long d, id;
  bool operator<(const node &A) const { return d > A.d; }
};
vector<node> ac[maxn];
long long dis[maxn];
int pre[maxn], Id[maxn];
bool done[maxn];
vector<pair<int, int> > bc[maxn];
void djs() {
  for (int i = 1; i <= n; i++) dis[i] = INF;
  dis[1] = 0;
  priority_queue<node> Q;
  Q.push(node{1, 0, 0});
  while (!Q.empty()) {
    node now = Q.top();
    Q.pop();
    int k = now.u;
    if (done[k]) continue;
    bc[pre[k]].push_back(make_pair(k, Id[k]));
    done[k] = 1;
    for (auto e : ac[k]) {
      int v = e.u, d = e.d, id = e.id;
      if (dis[v] > dis[k] + d) {
        dis[v] = dis[k] + d;
        pre[v] = k;
        Id[v] = id;
        Q.push(node{v, dis[v], 0});
      }
    }
  }
}
vector<int> ans1;
void bfs() {
  int temp = 0, ans = 0;
  queue<int> Q;
  Q.push(1);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (temp == k) break;
    for (auto e : bc[u]) {
      int v = e.first, id = e.second;
      ans1.push_back(id + 1);
      ans++;
      temp++;
      if (temp == k) break;
      Q.push(v);
    }
    if (temp == k) break;
  }
  printf("%d\n", temp);
  int flag = 0;
  for (auto e : ans1) {
    if (flag) printf(" ");
    flag = 1;
    printf("%d", e);
  }
}
int main() {
  read(n), read(m), read(k);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    read(a), read(b), read(c);
    ac[a].push_back(node{b, c, i});
    ac[b].push_back(node{a, c, i});
  }
  djs();
  bfs();
  return 0;
}
