#include <bits/stdc++.h>
using namespace std;
bool print;
struct DisjointSet {
  vector<int> lab, Rank;
  DisjointSet() {}
  DisjointSet(int n) {
    lab.assign(n + 5, -1);
    Rank.assign(n + 5, 0);
  }
  int root(int u) { return (lab[u] == -1) ? u : lab[u] = root(lab[u]); }
  void merge(int u, int v) {
    int a = root(u), b = root(v);
    if (a == b) return;
    if (Rank[a] > Rank[b]) swap(a, b);
    lab[a] = b;
    Rank[b] += (Rank[a] == Rank[b]);
  }
};
const double EPS = 1e-7;
struct Edge {
  int u, v, id;
  double w;
  Edge() {}
  Edge(int u, int v, double w, int id) : u(u), v(v), w(w), id(id) {}
  bool operator<(const Edge rhs) const { return w < rhs.w; }
};
const int N = 5e3 + 5, W = 1e5 + 5;
int n, m, k;
Edge dd[W];
bool in_res[W];
vector<Edge> EdgeList, E1, E2;
void input() {
  scanf("%d %d %d", &n, &m, &k);
  for (int nhi = (1), _b = (m); nhi <= _b; nhi++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    dd[nhi] = Edge(u, v, w, nhi);
    if (u == 1 || v == 1)
      E1.push_back(Edge(u, v, w, nhi));
    else
      E2.push_back(Edge(u, v, w, nhi));
  }
}
int check(double mid) {
  EdgeList.clear();
  memset(in_res, 0, sizeof in_res);
  for (Edge& e : E1) e.w += mid;
  merge(E1.begin(), E1.end(), E2.begin(), E2.end(), back_inserter(EdgeList));
  if (print) cerr << fixed << setprecision(9) << mid << " : ";
  for (Edge e : EdgeList)
    if (print) cerr << e.w << ' ';
  DisjointSet DSU = DisjointSet(n);
  int ret = 0;
  for (Edge e : EdgeList) {
    if (DSU.root(e.u) != DSU.root(e.v)) {
      DSU.merge(e.u, e.v);
      in_res[e.id] = 1;
      if (e.u == 1 || e.v == 1) {
        ret++;
      }
    }
  }
  for (Edge& e : E1) e.w -= mid;
  return ret;
}
void solve() {
  sort(E1.begin(), E1.end());
  sort(E2.begin(), E2.end());
  for (int i = 0, _n = (E1.size()); i < _n; i++) {
    E1[i].w += EPS * i;
  }
  double l = -W, r = W, increment = -W - 1;
  while (r - l > EPS) {
    double mid = (l + r) / 2;
    if (print) cerr << l << ' ' << r << ' ' << mid << '\n';
    int tmp = check(mid);
    if (print) cerr << "   Final res : " << tmp << '\n';
    if (tmp == k) increment = mid;
    if (tmp > k)
      l = mid;
    else
      r = mid;
  }
  if (abs(increment + W + 1) <= EPS)
    printf("-1\n");
  else {
    check(increment);
    if (print) cerr << '\n' << "increment : " << increment << '\n';
    cout << n - 1 << '\n';
    int tmp = 0;
    for (int i = (1), _b = (m); i <= _b; i++)
      if (in_res[i]) {
        cout << i << ' ';
        tmp += dd[i].w;
      }
    if (print) cerr << "Cost " << tmp << '\n';
    cout << '\n';
  }
}
int main(int argc, char const* argv[]) {
  print = 0;
  clock_t tStart = clock();
  input();
  solve();
  fprintf(stderr, "Time taken: %.2fs\n",
          (double)(clock() - tStart) / CLOCKS_PER_SEC);
  return 0;
}
