#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int a, b, pos;
  double w;
};
Edge e[100010];
Edge e1[100010];
int f[5010];
int ans[100010];
int n, m, k, i, cnt, a, b;
double l = -1e6, r = 1e6, mid;
bool operator<(const Edge& e, const Edge& e1) { return e.w < e1.w; }
int find(int x) {
  if (x != f[x]) f[x] = find(f[x]);
  return f[x];
}
int kruskal() {
  int i, t = 0, now = 0;
  for (i = 1; i <= m; i++) {
    e1[i] = e[i];
    e1[i].a == 1 ? e1[i].w += mid : 0;
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  sort(e1 + 1, e1 + m + 1);
  for (i = 1; i <= m; i++) {
    a = find(e1[i].a);
    b = find(e1[i].b);
    if (a != b) {
      ans[++t] = e1[i].pos;
      now += e1[i].a == 1;
      f[a] = b;
    }
  }
  return now;
}
int main() {
  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].w);
    if (e[i].a > e[i].b) swap(e[i].a, e[i].b);
    e[i].pos = i;
  }
  while (l < r) {
    mid = (l + r) / 2;
    cnt = kruskal();
    if (cnt == k) break;
    if (cnt < k)
      r = mid;
    else
      l = mid;
  }
  if (cnt == k) {
    printf("%d\n", n - 1);
    for (i = 1; i < n; ++i) printf("%d ", ans[i]);
  } else
    printf("-1\n");
  return 0;
}
