#include <bits/stdc++.h>
using namespace std;
int n, m, k, p[5009];
vector<int> ans;
int findset(int x) { return p[x] == x ? x : p[x] = findset(p[x]); }
void unionset(int x, int y) { p[findset(x)] = findset(y); }
struct node {
  int u, v, id;
  double w;
  bool operator<(const node &rhs) const { return w < rhs.w; }
} a[200009], b[200009];
int check(double x) {
  for (int i = 0; i < m; i++) {
    b[i] = a[i];
    if (b[i].u == 1) b[i].w += x;
  }
  sort(b, b + m);
  int cnt = 0, num = 0;
  for (int i = 0; i <= n; i++) p[i] = i;
  ans.clear();
  for (int i = 0; i < m; i++) {
    if (findset(b[i].u) == findset(b[i].v)) continue;
    unionset(b[i].u, b[i].v);
    ans.push_back(b[i].id);
    if (b[i].u == 1) cnt++;
    num++;
  }
  if (num != n - 1)
    return -1;
  else
    return cnt;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> a[i].u >> a[i].v >> a[i].w;
    a[i].id = i + 1;
    if (a[i].u > a[i].v) swap(a[i].u, a[i].v);
  }
  double L = -1e9, R = 1e9;
  int cur = -1;
  for (int i = 0; i < 100; i++) {
    double M = (L + R) / 2;
    cur = check(M);
    if (cur > k)
      L = M;
    else if (cur < k)
      R = M;
    else
      break;
  }
  if (cur != k) {
    puts("-1");
  } else {
    cout << ans.size() << endl;
    for (int i = 0; i < (int)ans.size(); i++) cout << ans[i] << " ";
  }
  return 0;
}
