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 = 5000;
const int MAXM = 100000;
const int INF = 0x3f3f3f3f;
int Fa[MAXN + 10], mn_id[MAXN + 10], id[MAXM + 10], dis[MAXN + 10],
    lis[MAXN + 10], oth[MAXN + 10];
int min_id[MAXN + 10];
bool used[MAXN + 10];
pair<int, pair<int, int> > edg[MAXM + 10];
struct node {
  int v, id;
  node *next;
} Edges[MAXN * 2 + 10], *ecnt = Edges, *adj[MAXN + 10];
void addedge(int u, int v, int id) {
  ++ecnt;
  ecnt->v = v;
  ecnt->id = id;
  ecnt->next = adj[u];
  adj[u] = ecnt;
}
bool cmp(int a, int b) { return edg[a].first < edg[b].first; }
int FindFa(int u) {
  if (!Fa[u]) return u;
  return Fa[u] = FindFa(Fa[u]);
}
bool Union(int x, int y) {
  int f1 = FindFa(x);
  int f2 = FindFa(y);
  if (f1 == f2) return false;
  Fa[f1] = f2;
  return true;
}
void dfs(int u, int fa, int _prev) {
  min_id[u] = _prev;
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa) continue;
    int nex =
        (_prev == -1 || (edg[_prev].first < edg[p->id].first)) ? p->id : _prev;
    dfs(p->v, u, nex);
  }
}
int main() {
  int n, m, k, u, v, w;
  scanf("%d%d%d", &n, &m, &k);
  edg[0].first = INF;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    if (u > v) swap(u, v);
    edg[i] = make_pair(w, make_pair(u, v));
    id[i] = i;
  }
  sort(id + 1, id + 1 + m, cmp);
  int lcnt = 0;
  for (int i = 1; i <= m; i++) {
    if (edg[id[i]].second.first == 1) {
      v = edg[id[i]].second.second;
      if (edg[dis[v]].first > edg[id[i]].first) dis[v] = id[i];
    } else {
      if (Union(edg[id[i]].second.first, edg[id[i]].second.second)) {
        lis[++lcnt] = id[i];
      }
    }
  }
  int ocnt = 0, cur_cnt = 0;
  sort(dis + 1, dis + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    if (!dis[i]) break;
    if (Union(1, edg[dis[i]].second.second))
      lis[++lcnt] = dis[i], cur_cnt++;
    else
      oth[++ocnt] = dis[i];
  }
  if (lcnt != n - 1 || cur_cnt > k) {
    printf("-1\n");
    return 0;
  }
  while (cur_cnt < k) {
    int diff = INF;
    int rpid = -1, insid = -1;
    memset(adj, 0, sizeof adj);
    ecnt = Edges;
    for (int j = 1; j <= lcnt; j++) {
      addedge(edg[lis[j]].second.first, edg[lis[j]].second.second, lis[j]);
      addedge(edg[lis[j]].second.second, edg[lis[j]].second.first, lis[j]);
    }
    for (node *p = adj[1]; p; p = p->next) dfs(p->v, 1, -1);
    for (int i = 1; i <= ocnt; i++) {
      if (used[i]) continue;
      v = edg[oth[i]].second.second;
      int cur_diff = edg[oth[i]].first - edg[min_id[v]].first;
      if (cur_diff < diff) {
        diff = cur_diff;
        rpid = min_id[v];
        insid = i;
      }
    }
    if (rpid == -1) {
      printf("-1\n");
      return 0;
    }
    used[insid] = true;
    insid = oth[insid];
    cur_cnt++;
    for (int i = 1; i <= lcnt; i++) {
      if (lis[i] == rpid) {
        lis[i] = insid;
        break;
      }
    }
  }
  printf("%d\n", n - 1);
  for (int i = 1; i < n; i++) printf("%d ", lis[i]);
  return 0;
}