Problem: The MST (Meaningless State Team) company won another tender for an important state reform in Berland.

There are n cities in Berland, some pairs of the cities are connected by roads. Each road has its price. One can move along any road in any direction. The MST team should carry out the repair works on some set of roads such that one can get from any city to any other one moving only along the repaired roads. Moreover, this set should contain exactly k capital roads (that is, the roads that start or finish in the capital). The number of the capital is 1.

As the budget has already been approved, the MST Company will profit by finding the set with minimum lengths of roads.

Input

The first input line contains three integers n, m, k (1 ≤ n ≤ 5000;0 ≤ m ≤ 105;0 ≤ k < 5000), where n is the number of cities in the country, m is the number of roads in the country, k is the number of capital roads in the required set. Then m lines enumerate the roads in question. Each road is specified by three numbers ai, bi, wi (1 ≤ ai, bi ≤ n; 1 ≤ w ≤ 105), where ai, bi are the numbers of cities linked by a road and wi is its length. 

Between each pair of cities no more than one road exists. There are no roads that start and finish in one city. The capital's number is 1.

Output

In the first line print the number of roads in the required set. The second line should contain the numbers of roads included in the sought set. If the sought set does not exist, print -1.

Examples

Input

4 5 2
1 2 1
2 3 1
3 4 1
1 3 3
1 4 2


Output

3
1 5 2 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const int maxn = 5e3 + 5, maxm = 1e5 + 5;
int n, m, k, slp, ans, vis[maxn], we, be;
struct Edge {
  int x, y, val, id;
  bool operator<(Edge b) const { return val < b.val; }
} w[maxm], b[maxm];
struct DSU {
  int fa[maxn];
  void clr() {
    for (int i = 1; i <= n; ++i) fa[i] = i;
  }
  int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
} dsu;
namespace wqs {
struct pair {
  int wcnt, vals;
  pair(int X = 0, int Y = 0) : wcnt(X), vals(Y){};
};
pair Kruskal(int V) {
  int wcnt = 0, vals = 0, fx, fy, i, j;
  dsu.clr();
  for (i = 1; i <= we; ++i) w[i].val += V;
  for (i = 1, j = 1;; ++i) {
    while (j <= we && w[j].val < b[i].val) {
      fx = dsu.getfa(w[j].x), fy = dsu.getfa(w[j].y);
      if (fx ^ fy) dsu.fa[fx] = fy, vals += w[j].val, ++wcnt;
      ++j;
    }
    if (i == be + 1) break;
    fx = dsu.getfa(b[i].x), fy = dsu.getfa(b[i].y);
    if (fx ^ fy) dsu.fa[fx] = fy, vals += b[i].val;
  }
  for (i = 1; i <= we; ++i) w[i].val -= V;
  return pair(wcnt, vals);
}
void Solve() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1, x, y, z; i <= m; ++i) {
    scanf("%d %d %d", &x, &y, &z);
    if (x == 1 || y == 1)
      vis[x + y - 1] = 1, w[++we] = (Edge){x, y, z, i};
    else
      b[++be] = (Edge){x, y, z, i};
  }
  std ::sort(w + 1, w + we + 1), std ::sort(b + 1, b + be + 1);
  int cnt;
  cnt = 0;
  for (int i = 2; i <= n; ++i) cnt += vis[i];
  if (cnt < k) puts("-1"), exit(0);
  cnt = 0, dsu.clr();
  for (int i = 1, fx, fy; i <= be; ++i) {
    fx = dsu.getfa(b[i].x), fy = dsu.getfa(b[i].y);
    if (fx != fy) dsu.fa[fx] = fy;
  }
  for (int i = 2; i <= n; ++i) vis[i] = 0;
  for (int i = 2; i <= n; ++i) vis[dsu.getfa(i)] = 1;
  for (int i = 2; i <= n; ++i) cnt += vis[i];
  if (cnt > k) puts("-1"), exit(0);
  b[be + 1].val = INT_MAX;
  int l = -1e5, r = 1e5;
  while (l <= r) {
    int mid = l + r >> 1;
    pair ret = Kruskal(mid);
    if (ret.wcnt <= k)
      slp = mid, r = mid - 1;
    else
      l = mid + 1;
  }
}
}  // namespace wqs
namespace construct {
int eval[maxn], evis[maxm], eid[maxn], head[maxn], tot;
struct Edge {
  int next, to;
} e[maxn << 1];
void add_edge(int x, int y) { e[++tot] = (Edge){head[x], y}, head[x] = tot; }
void DFS(int u, int F, int rt) {
  dsu.fa[u] = rt;
  for (int i = head[u], v; v = e[i].to, i; i = e[i].next)
    if (v != F) DFS(v, u, rt);
}
void Solve() {
  printf("%d\n", n - 1);
  int wcnt = 0, fx, fy, i, j;
  dsu.clr();
  for (i = 1; i <= we; ++i) w[i].val += slp;
  for (i = 1, j = 1;; ++i) {
    while (j <= we && w[j].val <= b[i].val) {
      fx = dsu.getfa(w[j].x), fy = dsu.getfa(w[j].y);
      if (fx ^ fy)
        dsu.fa[fx] = fy, eval[w[j].x + w[j].y - 1] = w[j].val,
        evis[eid[w[j].x + w[j].y - 1] = w[j].id] = 1, ++wcnt;
      ++j;
    }
    if (i == be + 1) break;
    fx = dsu.getfa(b[i].x), fy = dsu.getfa(b[i].y);
    if (fx ^ fy)
      dsu.fa[fx] = fy, add_edge(b[i].x, b[i].y), add_edge(b[i].y, b[i].x),
      evis[b[i].id] = 1;
  }
  dsu.clr();
  for (int i = 1; i <= n; ++i)
    if (eval[i]) DFS(i, 0, i);
  for (i = 1; wcnt > k; ++i) {
    if (evis[b[i].id]) continue;
    int fx = dsu.getfa(b[i].x), fy = dsu.getfa(b[i].y);
    if (fx != fy) {
      if (eval[fx] == b[i].val)
        dsu.fa[fx] = fy, --wcnt, evis[eid[fx]] = 0, evis[b[i].id] = 1;
      else if (eval[fy] == b[i].val)
        dsu.fa[fy] = fx, --wcnt, evis[eid[fy]] = 0, evis[b[i].id] = 1;
    }
  }
  for (int i = 1; i <= m; ++i)
    if (evis[i]) printf("%d ", i);
}
}  // namespace construct
int main() { return wqs::Solve(), construct::Solve(), 0; }