#include <bits/stdc++.h>
using namespace std;
int n, m;
int k;
bool debug = false;
int f[5005];
int ff(int x) { return x == f[x] ? x : f[x] = ff(f[x]); }
struct Edge {
  int i, a, b, w;
  double jw;
  bool operator<(const Edge &o) const { return jw < o.jw; }
};
vector<Edge> es;
vector<int> ans;
int kruskal(double mm) {
  int cnt = 0;
  for (Edge &e : es) {
    if (e.a == 1)
      e.jw = e.w + mm;
    else
      e.jw = e.w;
    e.jw += 1e-6 * e.i;
  }
  sort(es.begin(), es.end());
  ans.clear();
  for (int i = 1; i <= n; i++) f[i] = i;
  for (Edge e : es) {
    int fa = ff(e.a), fb = ff(e.b);
    if (fa != fb) {
      if (e.a == 1) cnt++;
      ans.push_back(e.i);
      f[fa] = fb;
    }
  }
  return cnt;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  Edge tt;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &tt.a, &tt.b, &tt.w);
    tt.i = i;
    if (tt.a > tt.b) swap(tt.a, tt.b);
    es.push_back(tt);
  }
  double l = -1e6, r = 1e6;
  int kk = 0;
  while (abs(l - r) > 1e-6) {
    double mm = (l + r) / 2;
    kk = kruskal(mm);
    if (kk == k)
      break;
    else if (kk < k) {
      r = mm;
    } else {
      l = mm;
    }
  }
  if (kk == k) {
    printf("%d\n", ans.size());
    for (int x : ans) printf("%d ", x);
  } else {
    puts("-1");
  }
  return 0;
}
