#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, maxn = 2e5 + 5;
const double eps = 1e-5;
int n, m, k, mst1 = 0, fa[maxn];
double mid;
struct edges {
  int x, y, v, id;
  bool operator<(edges b) const {
    double ax = 1.0 * v;
    if (x == 1) ax += mid;
    double bx = 1.0 * b.v;
    if (b.x == 1) bx += mid;
    return ax < bx;
  }
} e[maxn];
int find(int x) { return fa[x] == x ? fa[x] : fa[x] = find(fa[x]); }
void kruskal1() {
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= n; i++) fa[i] = i;
  int inmst = 0;
  for (int i = 1; i <= m; i++) {
    int fx = find(e[i].x), fy = find(e[i].y);
    if (fx == fy) continue;
    fa[fy] = fx;
    ++inmst;
    if (e[i].x == 1) ++mst1;
    if (inmst == n - 1) break;
  }
}
int ans[maxn], acnt = 0;
void kruskal2() {
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= n; i++) fa[i] = i;
  int inmst = 0;
  mst1 = 0;
  for (int i = 1; i <= m; i++) {
    int fx = find(e[i].x), fy = find(e[i].y);
    if (fx == fy) continue;
    if (mst1 + (e[i].x == 1) > k) continue;
    fa[fx] = fy;
    ++inmst;
    ans[++acnt] = e[i].id;
    if (e[i].x == 1) ++mst1;
    if (inmst == n - 1) break;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int de1 = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].v);
    e[i].id = i;
    if (e[i].x > e[i].y) swap(e[i].x, e[i].y);
    if (e[i].x == 1) ++de1;
  }
  mid = 0;
  kruskal1();
  if (de1 < k || (n > 1 && k == 0)) {
    puts("-1");
    return 0;
  }
  double l = -1e5, r = 1e5;
  while (r - l > eps && mst1 != k) {
    mst1 = 0;
    mid = (l + r) / 2.0;
    kruskal1();
    if (mst1 < k)
      r = mid;
    else
      l = mid;
  }
  if (mst1 != k) mid = (l + r) / 2.0;
  kruskal2();
  printf("%d\n", acnt);
  for (int i = 1; i <= acnt; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
