#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL * 1001 * 1001 * 1001 * 1001 * 1001 * 1001;
vector<pair<long long, long long> > g[300005];
vector<long long> gg[300005];
vector<pair<pair<long long, long long>, long long> > e;
long long d[300005], p[300005];
long long used[300005];
long long n, m, k;
set<pair<long long, long long> > lft;
vector<long long> ans, t;
void dfs(long long u) {
  used[u] = 1;
  for (long long i = 0; i < gg[u].size(); i++)
    if (!used[gg[u][i]]) dfs(gg[u][i]);
  t.push_back(u);
}
int main() {
  ios_base::sync_with_stdio(0);
  for (long long i = 0; i < 300005; i++) d[i] = INF;
  cin >> n >> m >> k;
  k = m - k;
  for (long long i = 0; i < m; i++) {
    long long a, b, w;
    cin >> a >> b >> w;
    if (a > b) swap(a, b);
    g[a].push_back(make_pair(b, w));
    g[b].push_back(make_pair(a, w));
    e.push_back(make_pair(make_pair(a, b), i));
  }
  priority_queue<pair<long long, long long> > q;
  q.push(make_pair(0, 1));
  d[1] = 0;
  while (!q.empty()) {
    long long v = q.top().second, cur_d = -q.top().first;
    q.pop();
    if (cur_d > d[v]) continue;
    for (size_t j = 0; j < g[v].size(); ++j) {
      long long to = g[v][j].first, len = g[v][j].second;
      if (d[v] + len < d[to]) {
        d[to] = d[v] + len;
        p[to] = v;
        q.push(make_pair(-d[to], to));
      }
    }
  }
  for (long long i = 2; i <= n; i++) {
    lft.insert(make_pair(min(i, p[i]), max(i, p[i])));
    gg[i].push_back(p[i]);
    gg[p[i]].push_back(i);
  }
  dfs(1);
  if (k <= m - (n - 1)) {
    k = m - (n - 1) - k;
    for (long long i = 0; i < e.size(); i++)
      if (lft.count(make_pair(e[i].first.first, e[i].first.second)))
        ans.push_back(e[i].second);
      else if (k) {
        ans.push_back(e[i].second);
        k--;
      }
  } else {
    k = k - (m - (n - 1));
    for (long long i = 0; i < k; i++)
      lft.erase(make_pair(min(t[i], p[t[i]]), max(t[i], p[t[i]])));
    for (long long i = 0; i < e.size(); i++)
      if (lft.count(make_pair(e[i].first.first, e[i].first.second)))
        ans.push_back(e[i].second);
  }
  cout << ans.size() << endl;
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
}
