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;
struct edge {
  int x, y, next, w, id;
  bool flag;
};
const int maxn = 5010, maxm = 100010, root = 1;
int n, m, d, num, head[maxn], fa[maxn], w[maxn], pre[maxn];
edge e[maxm], e2[maxm], ee[maxn << 2];
bool cmp(const edge &a, const edge &b) { return a.w < b.w; }
int find(int k) {
  if (fa[k] < 0)
    return k;
  else {
    fa[k] = find(fa[k]);
    return fa[k];
  }
}
inline void add(int a, int b, int c, int id) {
  num++;
  ee[num].next = head[a];
  head[a] = num;
  ee[num].y = b;
  ee[num].w = c;
  ee[num].flag = true;
  ee[num].id = id;
}
void dfs(int node) {
  for (int temp = head[node]; temp >= 0; temp = ee[temp].next)
    if (ee[temp].flag) {
      int j = ee[temp].y;
      if (fa[node] != j) {
        fa[j] = node;
        w[j] = max(w[node], ee[temp].w);
        dfs(j);
      }
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &d);
  int tot = 0, tot2 = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a != root && b != root) {
      e[tot].id = i;
      e[tot].x = a;
      e[tot].y = b;
      e[tot++].w = c;
    } else {
      e2[tot2].id = i;
      e2[tot2].x = a;
      e2[tot2].y = b;
      if (e2[tot2].x != root) swap(e2[tot2].x, e2[tot2].y);
      e2[tot2++].w = c;
    }
  }
  sort(e, e + tot, cmp);
  memset(head, -1, sizeof(head));
  num = -1;
  memset(fa, -1, sizeof(fa));
  int ans = 0, mm = 0;
  for (int i = 0; i < tot; i++) {
    int a = find(e[i].x), b = find(e[i].y);
    if (a != b) {
      fa[a] = b;
      add(e[i].x, e[i].y, e[i].w, e[i].id);
      add(e[i].y, e[i].x, e[i].w, e[i].id);
      ans += e[i].w;
      mm++;
    }
  }
  sort(e2, e2 + tot2, cmp);
  int ss = 0;
  for (int i = 0; i < tot2; i++) {
    int a = find(e2[i].y);
    if (a != root) {
      ans += e2[i].w;
      fa[a] = root;
      add(root, e2[i].y, e2[i].w, e2[i].id);
      add(e2[i].y, root, e2[i].w, e2[i].id);
      e2[i].flag = true;
      ss++;
      mm++;
    } else
      e2[i].flag = false;
  }
  if (ss > d || mm < n - 1) {
    printf("-1\n");
    return 0;
  }
  for (int temp = head[root]; temp >= 0; temp = ee[temp].next) {
    int j = ee[temp].y;
    fa[j] = root;
    w[j] = 0;
    dfs(j);
  }
  while (ss < d) {
    int mint = int(1e9), k = -1;
    for (int i = 0; i < tot2; i++)
      if (!e2[i].flag && e2[i].w - w[e2[i].y] < mint) {
        mint = e2[i].w - w[e2[i].y];
        k = i;
      }
    if (k < 0) break;
    e2[k].flag = true;
    int j = e2[k].y;
    while (w[fa[j]] == w[j]) j = fa[j];
    ss++;
    ans += mint;
    for (int temp = head[j]; temp >= 0; temp = ee[temp].next)
      if (ee[temp].y == fa[j]) {
        ee[temp].flag = false;
        ee[temp ^ 1].flag = false;
        break;
      }
    j = e2[k].y;
    add(root, j, e2[k].w, e2[k].id);
    add(j, root, e2[k].w, e2[k].id);
    w[j] = 0;
    fa[j] = root;
    dfs(j);
  }
  if (ss < d)
    printf("-1\n");
  else {
    printf("%d\n", n - 1);
    for (int i = 0; i <= num; i += 2)
      if (ee[i].flag) printf("%d ", ee[i].id + 1);
    printf("\n");
  }
  return 0;
}