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 long long int maxN = 1E5 + 10;
const long long int maxQ = 5E3 + 10;
const long long int mod = 1E9 + 7;
const long long int INF = 1E5 + 10;
long long int par[maxQ], hight[maxQ];
vector<long long int> mst_edge;
long long int n, m, k;
long long int root_deg;
struct edge {
  long long int first;
  long long int second;
  long long int weight;
  long long int ind;
};
edge a[maxN];
bool cmp(edge x, edge y) {
  if (x.weight == y.weight)
    if (y.first == 0 || y.second == 0) return true;
  return x.weight < y.weight;
}
long long int find_root(long long int vtx) {
  if (par[vtx] == vtx) return vtx;
  long long int ans = find_root(par[vtx]);
  par[vtx] = ans;
  return ans;
}
void merge(long long int u, long long int v) {
  if (hight[u] == hight[v]) {
    par[u] = v;
    hight[v]++;
  } else if (hight[u] > hight[v])
    par[v] = u;
  else
    par[u] = v;
}
bool disjoinset(long long int u, long long int v) {
  if (find_root(u) == find_root(v)) return true;
  return false;
}
bool MST(long long int x) {
  mst_edge.clear();
  for (long long int i = 0; i < n; ++i) {
    par[i] = i;
    hight[i] = 0;
  }
  for (long long int i = 0; i < m; ++i)
    if (a[i].first == 0 || a[i].second == 0) a[i].weight -= x;
  sort(a, a + m, cmp);
  root_deg = 0;
  for (long long int i = 0; i < m; ++i) {
    long long int u = a[i].first;
    long long int v = a[i].second;
    if (disjoinset(u, v) == false) {
      if (u == 0 || v == 0) {
        if (root_deg >= k)
          continue;
        else
          ++root_deg;
      }
      merge(find_root(u), find_root(v));
      mst_edge.push_back(a[i].ind);
    }
  }
  long long int cnt = 0;
  for (long long int i = 0; i < n; ++i)
    if (par[i] == i) ++cnt;
  if (cnt > 1) return false;
  for (long long int i = 0; i < m; ++i)
    if (a[i].first == 0 || a[i].second == 0) a[i].weight += x;
  if (root_deg == k) return true;
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n >> m >> k;
  for (long long int i = 0; i < m; ++i) {
    long long int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    a[i].ind = i;
    a[i].first = u;
    a[i].second = v;
    a[i].weight = w;
  }
  if (k == 0 && n == 1) {
    cout << 0 << "\n";
    return 0;
  }
  if (MST(INF) == false || k == 0) {
    cout << -1 << "\n";
    return 0;
  }
  long long int l = -1E5, r = 1E5;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    if (MST(mid) == true)
      r = mid;
    else
      l = mid;
  }
  if (r - l == 1) MST(r);
  cout << mst_edge.size() << "\n";
  for (long long int i = 0; i < mst_edge.size(); ++i)
    cout << mst_edge[i] + 1 << ' ';
  return 0;
}