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>
using namespace std;
vector<int> St;
pair<int, int> link[5010];
set<int> S;
int n, m, c1, c2, k, cntb, ans;
struct edge {
  int u, v, w, id;
  edge() {}
  edge(int u1, int v1, int w1, int id1) : u(u1), v(v1), w(w1), id(id1){};
  bool operator<(const edge &a) const { return w < a.w; }
} e[100010], f[5010], dp[5010];
int Adj[5010], nxt[100010], V[100010], val[100010], Id[100010], cp;
void AddEdge(int u, int v, int w, int id) {
  cp++;
  V[cp] = v, val[cp] = w, Id[cp] = id;
  nxt[cp] = Adj[u];
  Adj[u] = cp;
}
int fa[5010], vis[5010];
int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }
void Kruscal() {
  for (int i = 1; i <= n; i++) fa[i] = i;
  sort(e, e + c2);
  for (int i = 0; i < c2; i++)
    if (Find(e[i].u) != Find(e[i].v)) {
      fa[fa[e[i].u]] = fa[e[i].v];
      ans++;
      S.insert(e[i].id);
      AddEdge(e[i].u, e[i].v, e[i].w, e[i].id);
      AddEdge(e[i].v, e[i].u, e[i].w, e[i].id);
    }
}
bool TreeStructure() {
  Kruscal();
  for (int i = 2; i <= n; i++)
    if (!vis[Find(i)]) {
      vis[fa[i]] = 1;
      cntb++;
    }
  if (k < cntb) return 1;
  int cnt3 = 0;
  for (int i = 0; i < c1; i++) {
    int p = Find(f[i].v);
    if (!link[p].first || f[i].w < link[p].first) {
      if (!link[p].first) cnt3++;
      link[p].first = f[i].w;
      link[p].second = f[i].id;
    }
  }
  if (cnt3 < cntb) return 1;
  ans += cnt3;
  for (int i = 0; i < c1; i++) {
    int p = Find(f[i].v);
    if (link[p].second == f[i].id) {
      S.insert(f[i].id);
      St.push_back(f[i].v);
    }
  }
  return 0;
}
void dfs(int u, int pre) {
  for (int i = Adj[u]; i; i = nxt[i])
    if (V[i] != pre) {
      if (dp[u].w > val[i])
        dp[V[i]] = dp[u];
      else
        dp[V[i]] = edge(u, V[i], val[i], Id[i]);
      dfs(V[i], u);
    }
}
void Erase(int x) {
  int u = dp[x].u, v = dp[x].v;
  int i = Adj[u];
  if (V[i] == v)
    Adj[u] = nxt[i];
  else {
    int ls = i;
    i = nxt[i];
    for (; i; ls = i, i = nxt[i])
      if (V[i] == v) {
        nxt[ls] = nxt[i];
        break;
      }
  }
  i = Adj[v];
  if (V[i] == u)
    Adj[v] = nxt[i];
  else {
    int ls = i;
    i = nxt[i];
    for (; i; ls = i, i = nxt[i])
      if (V[i] == u) {
        nxt[ls] = nxt[i];
        break;
      }
  }
}
void TreeK() {
  for (int i = cntb + 1; i <= k; i++) {
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < St.size(); i++) {
      int v = St[i];
      dp[v].w = -1000010;
      dfs(v, 1);
    }
    int mx = -1000010, t, Addid;
    for (int i = 0; i < c1; i++)
      if (dp[f[i].v].w - f[i].w > mx) {
        mx = dp[f[i].v].w - f[i].w;
        t = f[i].v;
        Addid = f[i].id;
      }
    Erase(t);
    St.push_back(t);
    S.insert(Addid);
    S.erase(dp[t].id);
  }
}
int main() {
  int u, v, w;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    if (u == 1 || v == 1) {
      if (v == 1) v = u;
      f[c1++] = edge(1, v, w, i);
    } else
      e[c2++] = edge(u, v, w, i);
  }
  if (TreeStructure()) {
    printf("-1\n");
    return 0;
  }
  TreeK();
  printf("%d\n", ans);
  for (set<int>::iterator it = S.begin(); it != S.end(); it++)
    printf("%d ", *it);
  printf("\n");
}