#include <bits/stdc++.h>
using namespace std;
struct code {
  int node;
  long long cost;
  int index;
  bool operator>(code r) const { return cost > r.cost; }
};
int const NM = 3e5;
vector<code> v[1 + NM];
vector<int> sol;
long long dp[1 + NM], k;
bool viz[1 + NM];
priority_queue<code, vector<code>, greater<code> > q;
void shortest() {
  q.push({1, 0});
  while (!q.empty() && sol.size() < k) {
    code x = q.top();
    viz[x.node] = true;
    if (x.index) sol.push_back(x.index);
    while (q.size() && viz[q.top().node]) q.pop();
    for (auto i : v[x.node]) {
      if (dp[i.node] > dp[x.node] + i.cost) {
        dp[i.node] = dp[x.node] + i.cost;
        q.push({i.node, dp[i.node], i.index});
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back({b, c, i});
    v[b].push_back({a, c, i});
  }
  fill(dp + 2, dp + n + 1, (1LL << 60));
  shortest();
  cout << sol.size() << '\n';
  for (auto i : sol) cout << i << ' ';
  return 0;
}
