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 inf(1010101010);
struct uf {
  int par[5005], rank[5005];
  int ff(int x) { return par[x] == x ? x : par[x] = ff(par[x]); }
  void uu(int x, int y) {
    x = ff(x), y = ff(y);
    if (x == y) return;
    if (rank[x] > rank[y])
      par[y] = x;
    else if (rank[x] < rank[y])
      par[x] = y;
    else
      rank[x]++, par[y] = x;
  }
  uf(int n) {
    for (int i(0); i < (n); i++) par[i] = i, rank[i] = 0;
  }
};
int n, m, k;
int wt[100005];
pair<int, int> e[100005];
int perm[100005];
struct mycmp {
  bool operator()(int i, int j) const { return wt[i] < wt[j]; }
};
void kruskal_met_0(vector<int>& ret) {
  uf G(n);
  for (int i(0); i < (m); i++) {
    int eid(perm[i]), x(e[eid].first), y(e[eid].second);
    if (x == 0 || y == 0) {
      ret.push_back(eid);
      G.uu(x, y);
    }
  }
  for (int i(0); i < (m); i++) {
    int eid(perm[i]), x(e[eid].first), y(e[eid].second), xr(G.ff(x)),
        yr(G.ff(y));
    if (xr - yr) {
      ret.push_back(eid);
      G.uu(x, y);
    }
  }
  for (int i(0); i < (n); i++)
    if (G.ff(i) != G.ff(0)) {
      puts("-1");
      exit(0);
    }
}
void kruskal_wo_0(vector<int>& ret) {
  uf G(n);
  for (int i(0); i < (m); i++) {
    int eid(perm[i]), x(e[eid].first), y(e[eid].second), xr(G.ff(x)),
        yr(G.ff(y));
    if (x == 0 || y == 0) continue;
    if (xr - yr) {
      ret.push_back(eid);
      G.uu(x, y);
    }
  }
}
int koppel[5005];
int main() {
  cin >> n >> m >> k;
  int deg0(0);
  for (int i(0); i < (m); i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--, y--;
    wt[i] = w;
    e[i].first = x, e[i].second = y;
    if (x == 0 || y == 0) deg0++;
  }
  if (deg0 < k) {
    puts("-1");
    exit(0);
  }
  for (int i(0); i < (m); i++) perm[i] = i;
  sort(perm, perm + m, mycmp());
  vector<int> mst_met, mst_wo;
  kruskal_met_0(mst_met);
  kruskal_wo_0(mst_wo);
  uf G(n);
  for (int i(0); i < (n); i++) koppel[i] = inf;
  vector<int> doen;
  for (__typeof((mst_met).end()) it((mst_met).begin()); it != (mst_met).end();
       ++it) {
    int eid(*it), x(e[eid].first), y(e[eid].second), xr(G.ff(x)), yr(G.ff(y));
    if (x == 0)
      koppel[yr] = wt[eid];
    else if (y == 0)
      koppel[xr] = wt[eid];
    else {
      int mi(min(koppel[xr], koppel[yr]));
      koppel[xr] = koppel[yr] = mi;
      G.uu(x, y);
      doen.push_back(eid);
    }
  }
  for (int iteratie(0); iteratie < (deg0 - k); iteratie++) {
    pair<int, int> opt(inf, 0);
    for (__typeof((mst_wo).end()) it((mst_wo).begin()); it != (mst_wo).end();
         ++it) {
      int eid(*it), x(e[eid].first), y(e[eid].second), xr(G.ff(x)), yr(G.ff(y));
      if (xr == yr) continue;
      opt = min(opt, make_pair(wt[eid] - max(koppel[xr], koppel[yr]), eid));
    }
    if (opt.first == inf) {
      puts("-1");
      return 0;
    }
    int eid(opt.second), x(e[eid].first), y(e[eid].second), xr(G.ff(x)),
        yr(G.ff(y));
    int mik(min(koppel[xr], koppel[yr]));
    koppel[xr] = koppel[yr] = mik;
    G.uu(x, y);
    doen.push_back(eid);
  }
  uf T(n);
  for (__typeof((doen).end()) it((doen).begin()); it != (doen).end(); ++it) {
    int eid(*it), x(e[eid].first), y(e[eid].second);
    assert(T.ff(x) != T.ff(y));
    T.uu(x, y);
  }
  if (((int)(doen).size()) != n - 1 - k) {
    puts("-1");
    return 0;
  }
  for (int i(0); i < (m); i++) {
    int eid(perm[i]), x(e[eid].first), y(e[eid].second), xr(T.ff(x)),
        yr(T.ff(y));
    if (x == 0 || y == 0) {
      if (xr - yr) {
        doen.push_back(eid);
        T.uu(x, y);
      }
    }
  }
  cout << ((int)(doen).size()) << endl;
  int som(0);
  for (__typeof((doen).end()) it((doen).begin()); it != (doen).end(); ++it) {
    cout << (*it + 1) << " ";
    som += wt[*it];
  }
  cout << endl;
}