#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v, id, pre;
  double w;
  bool operator<(const Edge &b) const { return w < b.w; }
} e[200010], e1[2][200010];
int hh[2][5010], ecnt[2], n, m, k, p[5010], con[5010], idd[5010], vis[5010],
    pre[5010], maxid[5010], gett[5010];
double maxx[5010];
int usee[200010];
queue<int> q;
int find(int x) {
  if (x == p[x]) return x;
  return p[x] = find(p[x]);
}
void addEdge(Edge *e, int *hh, int u, int v, double w, int id, int &ecnt) {
  e[ecnt].u = u;
  e[ecnt].v = v;
  e[ecnt].w = w;
  e[ecnt].id = id;
  e[ecnt].pre = hh[u];
  hh[u] = ecnt++;
}
double mst(Edge *e, int m, int &now, int id, int &ecnt) {
  double sum = 0;
  sort(e, e + m);
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 0; i < m; i++) {
    int u = e[i].u, v = e[i].v, w = e[i].w;
    if (u == 1 || v == 1) continue;
    if (find(u) == find(v)) continue;
    p[find(u)] = find(v);
    sum += w;
    addEdge(e1[id], hh[id], u, v, w, e[i].id, ecnt);
    addEdge(e1[id], hh[id], v, u, w, e[i].id, ecnt);
  }
  memset(con, 0, sizeof(con));
  for (int i = 2; i <= n; i++) con[find(i)] = 1;
  now = 0;
  for (int i = 2; i <= n; i++)
    if (con[i] == 1) now++;
  memset(idd, -1, sizeof(idd));
  for (int i = 0; i < m; i++) {
    int u = e[i].u, v = e[i].v, w = e[i].w;
    if (u != 1 && v != 1) continue;
    if (u != 1) swap(u, v);
    if (idd[find(v)] == -1 || e[idd[find(v)]].w > w) idd[find(v)] = i;
  }
  for (int i = 2; i <= n; i++)
    if (con[i] == 1 && idd[i] == -1) now = 10000;
  for (int i = 2; i <= n; i++) {
    if (con[i] == 1) {
      sum += e[idd[i]].w;
      addEdge(e1[id], hh[id], e[idd[i]].u, e[idd[i]].v, e[idd[i]].w,
              e[idd[i]].id, ecnt);
      addEdge(e1[id], hh[id], e[idd[i]].v, e[idd[i]].u, e[idd[i]].w,
              e[idd[i]].id, ecnt);
    }
  }
  return sum;
}
void bfs(int node, int id) {
  memset(vis, 0, sizeof(vis));
  vis[node] = 1;
  while (!q.empty()) q.pop();
  q.push(node);
  memset(pre, -1, sizeof(pre));
  memset(maxx, 0, sizeof(maxx));
  memset(maxid, -1, sizeof(maxid));
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (int i = hh[id][node]; i != -1; i = e1[id][i].pre) {
      int v = e1[id][i].v;
      double w = e1[id][i].w;
      if (vis[v]) continue;
      pre[v] = node;
      q.push(v);
      vis[v] = 1;
      maxx[v] = maxx[pre[v]];
      maxid[v] = maxid[pre[v]];
      if (node == 1) continue;
      if (maxid[v] == -1 || w > maxx[v]) {
        maxid[v] = e1[id][i].id;
        maxx[v] = w;
      }
    }
  }
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    memset(gett, -1, sizeof(gett));
    for (int i = 0; i < m; i++) {
      scanf("%d%d%lf", &e[i].u, &e[i].v, &e[i].w);
      e[i].id = i;
    }
    int now;
    ecnt[0] = 0;
    memset(hh, -1, sizeof(hh));
    double ans = mst(e, m, now, 0, ecnt[0]);
    for (int i = 0; i < m; i++) {
      if (e[i].u == 1)
        gett[e[i].v] = i;
      else if (e[i].v == 1)
        gett[e[i].u] = i;
    }
    if (now > k) {
      puts("-1");
      continue;
    }
    int id = 1, total = 0;
    for (int i = now; i < k; i++) {
      id = 1 - id;
      bfs(1, id);
      double dis;
      int del, add;
      bool find = false;
      for (int j = 2; j <= n; j++) {
        if (gett[j] == -1) continue;
        int v = j;
        double w = e[gett[j]].w;
        if (pre[v] == 1) continue;
        if (maxid[v] == -1) continue;
        if (!find || dis > w - maxx[v]) {
          find = true;
          dis = w - maxx[v];
          del = maxid[v];
          add = gett[j];
        }
      }
      if (!find) {
        total = -1;
        break;
      } else
        ans = ans + dis;
      memset(hh[1 - id], -1, sizeof(hh[1 - id]));
      ecnt[1 - id] = 0;
      for (int i = 0; i < ecnt[id]; i++)
        if (e1[id][i].id != del)
          addEdge(e1[1 - id], hh[1 - id], e1[id][i].u, e1[id][i].v, e1[id][i].w,
                  e1[id][i].id, ecnt[1 - id]);
      addEdge(e1[1 - id], hh[1 - id], e[add].u, e[add].v, e[add].w, e[add].id,
              ecnt[1 - id]);
      addEdge(e1[1 - id], hh[1 - id], e[add].v, e[add].u, e[add].w, e[add].id,
              ecnt[1 - id]);
    }
    memset(usee, 0, sizeof(usee));
    id = 1 - id;
    if (total == -1)
      puts("-1");
    else {
      for (int i = 0; i < ecnt[id]; i++) usee[e1[id][i].id] = 1;
      int cntt = 0;
      for (int i = 0; i < m; i++)
        if (usee[i]) cntt++;
      printf("%d\n", cntt);
      for (int i = 0; i < m; i++)
        if (usee[i]) printf("%d ", i + 1);
      printf("\n");
    }
  }
  return 0;
}
