#include <bits/stdc++.h>
struct bg_state {
  long long cur, dist;
  bool operator>(const bg_state& o) const { return dist > o.dist; }
};
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long MAX_N = 3e5 + 7;
struct bg_edge {
  long long a, b, c, id;
} edges[MAX_N];
long long n, m, k, pred_in[MAX_N], dist[MAX_N];
std::pair<long long, long long> pred[MAX_N];
std::vector<bg_edge> gr[MAX_N];
void dijk(void) {
  memset(dist, 0x3f, sizeof(dist));
  std::fill(pred, pred + n, std::pair<long long, long long>{-1, -1});
  std::priority_queue<bg_state, std::vector<bg_state>, std::greater<bg_state>>
      pq;
  pq.push({0, dist[0] = 0});
  while (pq.size()) {
    const bg_state now = pq.top();
    pq.pop();
    if (now.dist > dist[now.cur]) continue;
    const long long cur = now.cur;
    for (const auto& nei : gr[cur])
      if (dist[nei.b] > nei.c + dist[cur]) {
        pq.push({nei.b, dist[nei.b] = nei.c + dist[cur]});
        pred[nei.b] = {cur, nei.id};
      }
  }
  for (long long i = 0; i < n; ++i) gr[i].clear();
  for (long long i = 0; i < n; ++i) {
    if (pred[i].first != -1) {
      const bg_edge& e = edges[pred[i].second];
      gr[e.a].push_back({e});
      gr[e.b].push_back({e.b, e.a, e.c, e.id});
    }
  }
  std::fill(pred, pred + n, std::pair<long long, long long>{-1, -1});
  memset(dist, 0x3f, sizeof(dist));
  dist[0] = 0;
  std::queue<long long> order;
  order.push(0);
  long long taken = 0;
  std::vector<long long> ids;
  while (order.size() && taken < k) {
    long long cur = order.front();
    order.pop();
    if (pred[cur].first != -1) {
      ids.push_back(pred[cur].second + 1);
      ++taken;
    }
    if (taken >= k) break;
    for (const auto& nei : gr[cur])
      if (dist[nei.b] > nei.c + dist[cur]) {
        dist[nei.b] = nei.c + dist[cur];
        pred[nei.b] = {cur, nei.id};
        order.push(nei.b);
      }
  }
  std::cout << taken << "\n";
  for (const auto& e : ids) std::cout << e << " ";
  std::cout << "\n";
}
int main(void) {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cin >> n >> m >> k;
  for (long long i = 0, a, b, c; i < m; ++i) {
    std::cin >> a >> b >> c;
    --a;
    --b;
    gr[a].push_back({a, b, c, i});
    gr[b].push_back({b, a, c, i});
    edges[i] = {a, b, c, i};
  }
  dijk();
  return 0;
}
