#include <bits/stdc++.h>
using namespace std;
struct edge {
  int a, b, pos;
  double weight;
};
int res[100005];
int f[100005];
edge e[100005];
edge e1[100005];
bool operator<(edge first, edge second) { return first.weight < second.weight; }
int search(int x) {
  if (f[x] == 0) return x;
  f[x] = search(f[x]);
  return f[x];
}
int kruskalAlgorithm(double x, int n, int m, int k) {
  int i, fx, fy, c, s;
  c = s = 0;
  for (i = 1; i <= m; ++i) {
    e1[i] = e[i];
    if (e1[i].a == 1) e1[i].weight += x;
  }
  memset(f, 0, sizeof(f));
  sort(&e1[1], &e1[m + 1]);
  for (i = 1; i <= m; ++i) {
    fx = search(e1[i].a);
    fy = search(e1[i].b);
    if (fx != fy) {
      res[++c] = e1[i].pos;
      if (e1[i].a == 1) ++s;
      f[fx] = fy;
    }
  }
  return s;
}
void StartMethod(int n, int m, int k) {
  int i, now;
  double l, r, mid;
  l = -1000000, r = 1000000;
  for (i = 1; i <= 100; ++i) {
    mid = (l + r) / 2;
    now = kruskalAlgorithm(mid, n, m, k);
    if (now == k) break;
    if (now < k)
      r = mid;
    else
      l = mid;
  }
  if (now == k) {
    printf("%d\n", n - 1);
    for (i = 1; i < n; ++i) printf("%d ", res[i]);
  } else
    printf("-1\n");
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%lf", &e[i].a, &e[i].b, &e[i].weight);
    if (e[i].a > e[i].b) swap(e[i].a, e[i].b);
    e[i].pos = i;
  }
  StartMethod(n, m, k);
  return 0;
}
