#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1061109567;
const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
const int maxn = 1e5 + 5;
struct node {
  int u, v, id;
  double w;
  bool operator<(node a) const { return w < a.w; }
} e[maxn], ee[maxn];
int n, m, flag[maxn], f[maxn];
int findd(int u) { return u == f[u] ? u : f[u] = findd(f[u]); }
int check(double x) {
  memcpy(ee, e, sizeof(e));
  for (int i = 0; i < m; i++) {
    if (ee[i].u == 1) {
      ee[i].w += x;
    }
  }
  for (int i = 1; i <= n; i++) f[i] = i;
  sort(ee, ee + m);
  memset(flag, 0, sizeof(flag));
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    int u = ee[i].u, v = ee[i].v;
    if (findd(u) != findd(v)) {
      f[findd(u)] = findd(v);
      flag[ee[i].id] = 1;
      if (u == 1) cnt++;
    }
  }
  return cnt;
}
int main() {
  int k;
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%lf", &e[i].u, &e[i].v, &e[i].w);
    e[i].id = i;
    if (e[i].u > e[i].v) swap(e[i].u, e[i].v);
    e[i].w += i * eps;
  }
  double l = -1e6, r = 1e6;
  int t = 60;
  while (t--) {
    double mid = (l + r) / 2;
    int tmp = check(mid);
    if (tmp >= k) {
      l = mid;
    } else {
      r = mid;
    }
  }
  int ans = check(l);
  if (ans == k) {
    cout << n - 1 << endl;
    for (int i = 0; i < m; i++) {
      if (flag[i]) printf("%d ", i + 1);
    }
  } else {
    puts("-1");
  }
  return 0;
}
