#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long double PI = 4 * atan(1);
long long n, m, k, g, h, w, dist[300001];
vector<pair<long long, pair<long long, long long>>> v[300001];
priority_queue<pair<long long, pair<long long, long long>>,
               vector<pair<long long, pair<long long, long long>>>,
               greater<pair<long long, pair<long long, long long>>>>
    pq;
vector<long long> ans;
bool visitedE[300001], visitedV[300001];
void DJ() {
  visitedV[1] = true;
  dist[1] = 0;
  for (auto a : v[1]) {
    pq.push({a.second.first, {a.first, a.second.second}});
  }
  while (ans.size() < k && !pq.empty()) {
    pair<long long, pair<long long, long long>> p = pq.top();
    pq.pop();
    if (!visitedV[p.second.first]) {
      visitedV[p.second.first] = true;
      visitedE[p.second.second] = true;
      ans.push_back(p.second.second);
      for (auto a : v[p.second.first]) {
        if (!visitedV[a.first] && !visitedE[a.second.second])
          pq.push({p.first + a.second.first, {a.first, a.second.second}});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> g >> h >> w;
    v[g].push_back({h, {w, i + 1}});
    v[h].push_back({g, {w, i + 1}});
  }
  DJ();
  cout << ans.size() << "\n";
  for (auto a : ans) cout << a << " ";
  return 0;
}
