#include <bits/stdc++.h>
using namespace std;
void solve() {}
const long long maxn = 300500;
struct Edge {
  long long to, cost, ind;
  Edge(long long too, long long costt, long long indd) {
    to = too;
    cost = costt;
    ind = indd;
  }
};
struct Compare {
  bool operator()(Edge &l, Edge &r) { return l.cost < r.cost; }
};
vector<Edge> G[maxn];
long long dis[maxn];
long long last[maxn];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (long long i = 1; i <= 3e5; i++) {
    dis[i] = 1e18;
    last[i] = -1;
  }
  long long n, m, k;
  cin >> n >> m >> k;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (long long i = 1; i <= m; i++) {
    long long u, v, cost;
    cin >> u >> v >> cost;
    G[u].emplace_back(v, cost, i);
    G[v].emplace_back(u, cost, i);
  }
  pq.emplace(0, 1);
  dis[1] = 0;
  long long used = 0;
  vector<long long> ans;
  while ((long long)pq.size() and used < k) {
    pair<long long, long long> S = pq.top();
    pq.pop();
    if (false) cerr << "on " << S.second << '\n';
    if (dis[S.second] != S.first) continue;
    if (last[S.second] != -1) {
      ans.emplace_back(last[S.second]);
      used++;
    }
    for (Edge e : G[S.second]) {
      if (dis[e.to] > (dis[S.second] + e.cost)) {
        if (false) cerr << "pushing to " << e.to << '\n';
        dis[e.to] = (dis[S.second] + e.cost);
        pq.emplace(dis[e.to], e.to);
        last[e.to] = e.ind;
      }
    }
  }
  cout << (long long)ans.size() << '\n';
  for (long long x : ans) {
    cout << x << " ";
  }
  cout << '\n';
}
