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;
const int maxn = 5005;
const int maxm = 100005;
int n, m, i, j, t, k, s, K, N, head[maxn], ed[maxn], bac[maxm], fat[maxn], tot,
    mx[maxn], pla[maxn], torot[maxn], rotnum[maxn], e1, e2;
struct egg {
  int p1, p2, len, id;
} eg[maxm];
struct Edge {
  int pre, nxt, id;
} lk[(maxm << 1) + (maxn << 1)];
bool cmp(egg x, egg y) { return x.len < y.len; }
int father(int x) { return x == fat[x] ? x : fat[x] = father(fat[x]); }
inline void ins(int x, int y, int iid) {
  lk[y] = (Edge){head[x], lk[head[x]].nxt, iid};
  lk[lk[head[x]].nxt].pre = y;
  lk[head[x]].nxt = y;
}
inline void del(int pl) {
  lk[lk[pl].pre].nxt = lk[pl].nxt;
  lk[lk[pl].nxt].pre = lk[pl].pre;
}
void dfs(int x, int y) {
  if (y == 1) mx[x] = 0, pla[x] = 0;
  for (int i = lk[head[x]].nxt; i != ed[x]; i = lk[i].nxt) {
    int des = eg[lk[i].id].p1 + eg[lk[i].id].p2 - x;
    if (des == y) continue;
    mx[des] = mx[x];
    pla[des] = pla[x];
    if (mx[des] < eg[lk[i].id].len)
      mx[des] = eg[lk[i].id].len, pla[des] = lk[i].id;
    dfs(des, x);
  }
  if (y != 1) {
    if (rotnum[x] && s > torot[x] - mx[x] && pla[x]) {
      s = torot[x] - mx[x];
      e1 = rotnum[x];
      e2 = pla[x];
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  memset(torot, 0x3f3f3f3f, sizeof(torot));
  for (i = 1; i <= m; ++i) {
    scanf("%d%d%d", &eg[i].p1, &eg[i].p2, &eg[i].len);
    eg[i].id = i;
  }
  sort(eg + 1, eg + m + 1, cmp);
  for (i = 1; i <= n; ++i) {
    fat[i] = i, head[i] = ++tot, ed[i] = ++tot;
    lk[head[i]].nxt = ed[i];
    lk[ed[i]].pre = head[i];
  }
  t = n - 1;
  for (i = 1; i <= m; ++i) {
    if (eg[i].p1 == 1 && torot[eg[i].p2] > eg[i].len)
      torot[eg[i].p2] = eg[i].len, rotnum[eg[i].p2] = i;
    if (eg[i].p2 == 1 && torot[eg[i].p1] > eg[i].len)
      torot[eg[i].p1] = eg[i].len, rotnum[eg[i].p1] = i;
    if (father(eg[i].p1) == father(eg[i].p2) || eg[i].p1 == 1 || eg[i].p2 == 1)
      continue;
    fat[father(eg[i].p1)] = father(eg[i].p2);
    ins(eg[i].p1, ++tot, i);
    ins(eg[i].p2, ++tot, i);
    --t;
    bac[i] = tot - 1;
  }
  if (t > K) {
    puts("-1");
    return 0;
  }
  for (i = 1; i <= m; ++i) {
    if (eg[i].p1 != 1 && eg[i].p2 != 1) continue;
    if (father(eg[i].p1) == father(eg[i].p2)) continue;
    fat[father(eg[i].p1)] = father(eg[i].p2);
    ins(eg[i].p1, ++tot, i);
    ins(eg[i].p2, ++tot, i);
    bac[i] = tot - 1;
  }
  for (i = 1; i <= n; ++i)
    if (father(i) != father(1)) break;
  if (i <= n) {
    puts("-1");
    return 0;
  }
  for (i = t + 1; i <= K; ++i) {
    s = 1919810114;
    e1 = e2 = 0;
    for (j = lk[head[1]].nxt; j != ed[1]; j = lk[j].nxt)
      dfs(eg[lk[j].id].p1 + eg[lk[j].id].p2 - 1, 1);
    del(bac[e2]);
    del(bac[e2] + 1);
    ins(1, ++tot, e1);
    ins(eg[e1].p1 + eg[e1].p2 - 1, ++tot, e1);
    bac[e1] = tot - 1;
  }
  printf("%d\n", n - 1);
  for (i = 1; i <= n; ++i) {
    for (j = lk[head[i]].nxt; j != ed[i]; j = lk[j].nxt)
      if (eg[lk[j].id].p1 == i) {
        printf("%d ", eg[lk[j].id].id);
      }
  }
  puts("");
  return 0;
}