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;
pair<pair<int, int>, pair<int, int> > lis[MAXM + 10];
pair<pair<int, int>, pair<int, int> > pool[MAXN + 10];
pair<pair<int, int>, pair<int, int> > cur[MAXN + 10];
bool vis[MAXN + 10], used[MAXN + 10];
int dis[MAXN + 10], did[MAXN + 10], n, m, k, Fa[MAXN + 10], pcnt;
struct node {
  int v, w, id;
  node *next;
} Edges[MAXN * 2 + 10], *ecnt = Edges, *adj[MAXN + 10];
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 addedge(int u, int v, int w, int id) {
  ++ecnt;
  ecnt->v = v;
  ecnt->w = w;
  ecnt->id = id;
  ecnt->next = adj[u];
  adj[u] = ecnt;
}
void dfs(int u, int fa) {
  for (node *p = adj[u]; p; p = p->next) {
    if (p->v == fa) continue;
    if (u == 1)
      dis[p->v] = -INF, did[p->v] = -1;
    else {
      if (p->w > dis[u]) {
        dis[p->v] = p->w;
        did[p->v] = p->id;
      } else {
        dis[p->v] = dis[u];
        did[p->v] = did[u];
      }
    }
    dfs(p->v, u);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (!k) {
    if (n == 1)
      printf("0\n");
    else
      printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &lis[i].second.first, &lis[i].second.second,
          &lis[i].first.first);
    if (lis[i].second.first > lis[i].second.second)
      swap(lis[i].second.first, lis[i].second.second);
    lis[i].first.second = i;
  }
  sort(lis + 1, lis + 1 + m);
  int cnt = 0, cur_deg = 0;
  for (int i = 1; i <= m; i++) {
    if (lis[i].second.first == 1) continue;
    if (Union(lis[i].second.first, lis[i].second.second)) cur[++cnt] = lis[i];
  }
  for (int i = 1; i <= m; i++) {
    if (lis[i].second.first != 1) continue;
    if (Union(lis[i].second.first, lis[i].second.second)) {
      cur[++cnt] = lis[i];
      cur_deg++;
    } else if (!vis[lis[i].second.second]) {
      vis[lis[i].second.second] = true;
      pool[++pcnt] = lis[i];
    }
  }
  if (cur_deg > k || cnt != n - 1) {
    printf("-1\n");
    return 0;
  }
  k -= cur_deg;
  while (k--) {
    int eid = -1, min_v = INF;
    memset(adj, 0, sizeof adj);
    ecnt = Edges;
    for (int i = 1; i < n; i++) {
      addedge(cur[i].second.first, cur[i].second.second, cur[i].first.first, i);
      addedge(cur[i].second.second, cur[i].second.first, cur[i].first.first, i);
    }
    dfs(1, 0);
    for (int i = 1; i <= pcnt; i++) {
      if (used[i]) continue;
      if (did[pool[i].second.second] == -1) continue;
      int cost = pool[i].first.first - dis[pool[i].second.second];
      if (cost < min_v) {
        min_v = cost;
        eid = i;
      }
    }
    if (eid == -1) {
      printf("-1\n");
      return 0;
    }
    cur[did[pool[eid].second.second]] = pool[eid];
    used[eid] = true;
  }
  printf("%d\n", n - 1);
  for (int i = 1; i < n; i++)
    printf("%d%c", cur[i].first.second, i == n - 1 ? '\n' : ' ');
  return 0;
}