#include <bits/stdc++.h>
using namespace std;
int n, m, k;
struct node {
  int u, v, val, id;
  node() {}
  node(int u1, int v1, int id1, int val1) : u(u1), v(v1), id(id1), val(val1) {}
  bool operator<(const node &a) const {
    if (val != a.val) return val < a.val;
    return u < a.u;
  }
} l[100010];
vector<node> spe, del;
vector<int> id;
vector<int> a[100010], idx[100010];
int sum, ans, fa[100010], fav[100010];
bool used[100010];
int get_fa(int x) {
  if (fa[x] == 0) return x;
  fa[x] = get_fa(fa[x]);
  return fa[x];
}
void dfs(int x, int f, int id) {
  if (f != 1 && f != 0) {
    if (del[fav[f]].val > del[id].val)
      fav[x] = fav[f];
    else
      fav[x] = id;
  }
  for (int i = 0; i < a[x].size(); i++) {
    if (a[x][i] == f) continue;
    dfs(a[x][i], x, idx[x][i]);
  }
}
void build() {
  memset(a, 0, sizeof a);
  memset(idx, 0, sizeof idx);
  memset(fav, 0, sizeof fav);
  for (int i = 0; i < del.size(); i++)
    if (used[i] == 1) {
      int u = del[i].u, v = del[i].v, val = del[i].val;
      a[u].push_back(v);
      a[v].push_back(u);
      idx[u].push_back(i);
      idx[v].push_back(i);
    }
  dfs(1, 0, 0);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int u, v, val;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &val);
    l[i] = node(u, v, i, val);
  }
  sort(l + 1, l + 1 + m);
  for (int i = 1; i <= m; i++) {
    int u = l[i].u, v = l[i].v, val = l[i].val;
    if (u == 1 || v == 1) continue;
    int fu = get_fa(u);
    int fv = get_fa(v);
    if (fu != fv) {
      fa[fu] = fv;
      sum += val;
      del.push_back(l[i]);
      used[del.size() - 1] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    int u = l[i].u, v = l[i].v, val = l[i].val;
    if (u != 1 && v != 1) continue;
    if (v == 1) swap(u, v);
    del.push_back(l[i]);
    spe.push_back(l[i]);
    id.push_back(del.size() - 1);
    int fu = get_fa(u);
    int fv = get_fa(v);
    if (fu != fv) {
      fa[fu] = fv;
      sum += val;
      used[del.size() - 1] = 1;
      k--;
    }
  }
  ans = sum;
  while (k > 0) {
    build();
    int add = -1, maxd, delx;
    for (int i = 0; i < spe.size(); i++) {
      if (used[id[i]] == 1) continue;
      int u = spe[i].u, v = spe[i].v, val = spe[i].val;
      if (v == 1) swap(u, v);
      int maxv = del[fav[v]].val;
      if (add == -1 || maxd < maxv - val) {
        add = id[i];
        delx = fav[v];
        maxd = maxv - val;
      }
    }
    if (add == -1) break;
    used[add] = 1;
    used[delx] = 0;
    sum -= maxd;
    ans = min(ans, sum);
    k--;
  }
  if (k != 0) {
    printf("-1");
    return 0;
  }
  printf("%d\n", n - 1);
  for (int i = 0; i < del.size(); i++)
    if (used[i] == 1) {
      printf("%d ", del[i].id);
    }
}
