#include <bits/stdc++.h>
using namespace std;
int parent[100005];
double low = -1e8 * 1.000000000000;
double high = 1e8 * 1.000000000000, mid;
int ans[100008], p, e, n, k;
class edge {
 public:
  double wt;
  int src;
  int dest;
  int pos;
} obj[100008], obj1[100004], obj2[100005];
void change_weight(double m) {
  for (int i = 0; i < e; i++) {
    obj1[i].src = obj[i].src;
    obj1[i].dest = obj[i].dest;
    obj1[i].pos = obj[i].pos;
    if (obj[i].src == 1) {
      obj1[i].wt = obj[i].wt * m;
    } else {
      obj1[i].wt = obj[i].wt;
    }
  }
}
int calcparent(int x) {
  if (parent[x] == x)
    return x;
  else
    return parent[x] = (calcparent(parent[x]));
}
bool checkvalid(edge a) {
  if (calcparent(a.src) == calcparent(a.dest))
    return false;
  else
    return true;
}
bool myfunc(edge a, edge b) {
  double xx = a.wt, yy = b.wt;
  if (a.src == 1 && b.src == 1) return xx < yy;
  if (a.src == 1) xx += mid;
  if (b.src == 1) yy += mid;
  return xx < yy;
}
int kruskals(int flag) {
  int now = 0, p = 0, j = 0;
  sort(obj, obj + e, myfunc);
  int i = 0;
  while (j < n - 1 && i < e) {
    bool a = checkvalid(obj[i]);
    if (a) {
      if (flag)
        if ((flag == 1) && (obj[i].src == 1) && (now >= k)) {
          i++;
          continue;
        }
      if (obj[i].src == 1) now++;
      ans[p++] = obj[i].pos;
      int galat = calcparent(obj[i].dest), galat2 = calcparent(obj[i].src);
      parent[galat] = galat2;
      i++;
      j++;
    } else {
      i++;
    }
  }
  return (now);
}
int main() {
  int now;
  cin >> n >> e >> k;
  for (int i = 0; i < e; i++) {
    int s, d;
    double w;
    cin >> s >> d >> w;
    obj[i].wt = w;
    obj[i].src = s;
    obj[i].dest = d;
    if (obj[i].src > obj[i].dest) swap(obj[i].src, obj[i].dest);
    obj[i].pos = i + 1;
  }
  int counter = 0;
  while (high - low > 0.01) {
    for (int i = 0; i <= n; i++) parent[i] = i;
    mid = (low + high) * (0.50000000000);
    now = kruskals(0);
    if (now == k) break;
    if (now < k)
      high = mid;
    else
      low = mid;
  }
  if (k == 0 && n > 1) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i <= n; i++) parent[i] = i;
  mid = (low + high) / 2;
  now = kruskals(1);
  if (now == k) {
    cout << n - 1 << "\n";
    for (int i = 0; i < n - 1; i++) {
      cout << ans[i] << " ";
    }
  } else
    cout << "-1";
  return (0);
}
