#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, k, parent[N];
struct edge {
  int u, v, id;
  double w;
  edge(int x = 0, int y = 0, double xd = 0., int z = 0) {
    v = x, u = y, id = z, w = xd;
  }
  bool operator<(edge b) const { return w < b.w; }
} edgg[N];
int get_parent(int v) {
  return parent[v] == v ? v : parent[v] = get_parent(parent[v]);
}
bool Union(int v, int u) {
  v = get_parent(v), u = get_parent(u);
  if (v == u) return false;
  parent[u] = v;
  return true;
}
bool check(double x) {
  iota(parent, parent + n + 1, 0);
  vector<edge> E;
  for (int i = 1; i <= m; i++) {
    if (edgg[i].v != 1 && edgg[i].u != 1) edgg[i].w += x;
    E.push_back(edgg[i]);
    if (edgg[i].v != 1 && edgg[i].u != 1) edgg[i].w -= x;
  }
  sort(E.begin(), E.end());
  vector<int> ans;
  int res = 0;
  for (auto e : E)
    if (Union(e.v, e.u)) {
      ans.push_back(e.id);
      res += (e.v == 1 || e.u == 1);
    }
  if (res == k) {
    cout << (int)(ans.size()) << '\n';
    for (auto e : ans) cout << e << ' ';
    cout << '\n';
    exit(0);
  }
  return res < k;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1, v, u, w; i <= m; i++) {
    cin >> v >> u >> w;
    edgg[i] = edge(v, u, w, i);
  }
  double l = -1e9, r = 1e9;
  for (int i = 0; i < 300; i++) {
    double mid = (l + r) / 2.;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << "-1\n";
  return 0;
}
