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 N = 5e5 + 5;
int n, m, s, need;
struct Edge {
  int a, b;
  long long c;
  int id;
} e[N], e1[N], e2[N];
int tot, tot1, tot2;
vector<int> G[N];
inline bool cmp(const Edge& x, const Edge& y) {
  if (x.c != y.c)
    return x.c < y.c;
  else
    return (x.a == s) + (x.b == s) > (y.a == s) + (y.b == s);
}
int par[N];
int Find(int x) {
  if (par[x] != x)
    return par[x] = Find(par[x]);
  else
    return x;
}
inline void MergeSort(Edge c[], Edge a[], Edge b[]) {
  tot = 0;
  int i = 1, j = 1;
  while (i <= tot1 && j <= tot2) {
    if (cmp(a[i], b[j]))
      c[++tot] = a[i++];
    else
      c[++tot] = b[j++];
  }
  while (i <= tot1) c[++tot] = a[i++];
  while (j <= tot2) c[++tot] = b[j++];
}
bool vis[N];
pair<long long, int> check(long long t) {
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= m; i++) e1[i].c -= t;
  MergeSort(e, e1, e2);
  pair<long long, int> res(0, 0);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1, cnt = 0; i <= m && cnt < n - 1; i++) {
    int x = Find(e[i].a), y = Find(e[i].b);
    if (x == y) continue;
    par[x] = y;
    res.first += e[i].c;
    res.second += (e[i].a == s) + (e[i].b == s);
    cnt++;
    vis[e[i].id] = true;
  }
  for (int i = 1; i <= m; i++) e1[i].c += t;
  return res;
}
pair<long long, int> calc(long long t) {
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= m; i++) e1[i].c -= t;
  MergeSort(e, e1, e2);
  int lst = 1;
  for (int i = 2; i <= m; i++) {
    if (e[i].c == e[lst].c) continue;
    random_shuffle(e + lst, e + i);
    lst = i;
  }
  random_shuffle(e + lst, e + m + 1);
  pair<long long, int> res(0, 0);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1, cnt = 0; i <= m && cnt < n - 1; i++) {
    int x = Find(e[i].a), y = Find(e[i].b);
    if (x == y) continue;
    par[x] = y;
    res.first += e[i].c;
    res.second += (e[i].a == s) + (e[i].b == s);
    cnt++;
    vis[e[i].id] = true;
  }
  for (int i = 1; i <= m; i++) e1[i].c += t;
  return res;
}
int main() {
  srand(time(0));
  int i;
  scanf("%d%d%d", &n, &m, &need);
  s = 1;
  for (i = 1; i <= n; i++) par[i] = i;
  for (i = 1; i <= m; i++) {
    scanf("%d%d%lld", &e[i].a, &e[i].b, &e[i].c);
    e[i].id = i;
    G[e[i].a].push_back(e[i].b);
    G[e[i].b].push_back(e[i].a);
    if (e[i].a ^ s && e[i].b ^ s)
      par[Find(e[i].a)] = Find(e[i].b), e2[++tot2] = e[i];
    else
      e1[++tot1] = e[i];
  }
  for (i = 1; i <= n; i++) {
    sort(G[i].begin(), G[i].end());
    G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
  }
  if ((int)G[s].size() < need) return puts("-1") & 0;
  int cnt = 0;
  for (i = 0; i < (int)G[s].size(); i++)
    if (Find(s) != Find(G[s][i])) {
      cnt++;
      par[Find(s)] = Find(G[s][i]);
    }
  if (cnt > need) return puts("-1") & 0;
  for (i = 1; i <= n; i++)
    if (Find(i) != Find(1)) return puts("-1") & 0;
  sort(e1 + 1, e1 + tot1 + 1, cmp);
  sort(e2 + 1, e2 + tot2 + 1, cmp);
  long long L = -1e7, R = 1e7, mid;
  while (L + 1 < R) {
    mid = (L + R) >> 1;
    if (check(mid).second >= need)
      R = mid;
    else
      L = mid;
  }
  while (calc(R).second != need)
    ;
  printf("%d\n", n - 1);
  for (i = 1; i <= m; i++)
    if (vis[i]) printf("%d ", i);
  puts("");
  return 0;
}