#include <bits/stdc++.h>
using namespace std;
long long n, m, k, id[5005];
vector<pair<pair<long double, long long>, pair<long long, long long> > > ed,
    ed1;
vector<pair<long long, pair<long long, long long> > > edges[200005];
vector<pair<long long, pair<long long, long long> > > edges2;
vector<long long> ans;
long long root(long long x) {
  if (id[x] == x) return x;
  return id[x] = root(id[x]);
}
void union1(long long x, long long y) {
  long long p = root(x);
  long long q = root(y);
  id[p] = id[q];
}
long long dfs(long double val) {
  long long cnt = 0;
  ed1 = ed;
  for (long long i = 1; i <= n; i++) id[i] = i;
  for (long long i = 0; i < (long long)ed1.size(); i++) {
    if (ed1[i].second.first == 1) ed1[i].first.first += val;
  }
  sort(ed1.begin(), ed1.end());
  for (long long i = 0; i < ed1.size(); i++) {
    long long x = ed1[i].second.first;
    long long y = ed1[i].second.second;
    long long s1 = root(x);
    long long s2 = root(y);
    if (s1 != s2) {
      id[s2] = s1;
      if (x == 1) cnt++;
      ans.push_back(ed1[i].first.second);
    }
  }
  return cnt;
}
long long kruskal(vector<pair<long long, pair<long long, long long> > > p) {
  for (long long i = 0; i < 200005; i++) id[i] = i;
  long long x, y;
  long long count = 0;
  long long cost, minimumCost = 0;
  for (long long i = 0; i < p.size(); ++i) {
    x = p[i].second.first;
    y = p[i].second.second;
    cost = p[i].first;
    if (root(x) != root(y)) {
      count++;
      minimumCost += cost;
      union1(x, y);
      if (count == (n - 1)) return minimumCost;
    }
  }
  if (count < (n - 1)) return -1;
  return minimumCost;
}
signed main() {
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    if (u > v) swap(u, v);
    ed.push_back(make_pair(make_pair(w, i), make_pair(u, v)));
    edges[i].push_back({w, {u, v}});
  }
  long double lo = -1e12, high = 1e12;
  for (long long i = 0; i < 200; i++) {
    ans.clear();
    long double mid = (lo + high) / 2;
    if (dfs(mid) < k)
      high = mid;
    else
      lo = mid;
  }
  ans.clear();
  if (dfs(lo) != k) {
    printf("-1\n");
    return 0;
  }
  cout << ans.size() << "\n";
  for (long long i = 0; i < ans.size(); i++) {
    auto v = edges[ans[i]][0];
    edges2.push_back(v);
    cout << ans[i] << " ";
  }
  sort(edges2.begin(), edges2.end());
  return 0;
}
