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;
long long par[5050];
long long root(long long a) {
  while (par[a] != -1) a = par[a];
  return a;
}
long long height[5050];
vector<pair<pair<double, long long>, pair<long long, long long>>> me;
vector<long long> one;
signed main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    double wt;
    cin >> a >> b >> wt;
    if (a == 1 || b == 1) {
      me.push_back({{wt, i}, {a, b}});
      one.push_back(1);
    } else
      me.push_back({{wt, i}, {a, b}});
  }
  sort(me.begin(), me.end());
  for (long long i = 0; i <= n; i++) {
    height[i] = 0;
    par[i] = -1;
  }
  long long x = 0;
  double ans = 0;
  long long xx = 0;
  vector<pair<long long, double>> vec;
  for (auto kk : me) {
    long long u = kk.second.first, v = kk.second.second;
    long long rot1 = root(u), rot2 = root(v);
    if (rot1 != rot2) {
      x++;
      ans += kk.first.first;
      if (height[rot1] > height[rot2])
        par[rot2] = rot1;
      else if (height[rot1] < height[rot2])
        par[rot1] = rot2;
      else {
        par[rot1] = rot2;
        height[rot2] += 1;
      }
      if (u == 1 || v == 1) {
        xx++;
        vec.push_back({1, kk.first.second});
      } else
        vec.push_back({10, kk.first.second});
    }
  }
  if (x < n - 1 || (k == 0 && n > 1)) {
    printf("-1\n");
    return 0;
  }
  sort(vec.begin(), vec.end());
  if (xx == k && x == n - 1) {
    printf("%lld\n", n - 1);
    for (long long i = 0; i < n - 1; i++) {
      cout << vec[i].second + 1 << " ";
    }
    cout << "\n";
    return 0;
  }
  if (k > one.size()) {
    printf("-1\n");
    return 0;
  }
  if (k == 0 && n == 1) {
    printf("0\n");
    return 0;
  }
  double l = -1e6 - 6, h = 1e6 + 6, mid;
  long long flag = 0;
  double ans1 = 9999999999999;
  long long flag1 = 0;
  double mid1 = 9999999999999;
  long long ime = 0;
  for (l = -1e6 - 6, h = 1e6 + 6; ime < 100 && x != k;
       (x < k) ? (h = mid, ime++, flag = 1)
               : ((x == k) ? (flag = 1) : (1), l = mid, mid1 = mid, ime++)) {
    x = 0;
    ans = 0;
    vec.clear();
    for (long long i = 0; i <= n; i++) {
      par[i] = -1;
      height[i] = 0;
    }
    mid = (l + h) / 2;
    for (long long i = 0; i < m; i++) {
      if (me[i].second.second == 1 || me[i].second.first == 1) {
        me[i].first.first += mid;
      }
    }
    sort(me.begin(), me.end());
    for (auto kk : me) {
      long long u = kk.second.first, v = kk.second.second;
      long long rot1 = root(u), rot2 = root(v);
      if (rot1 == rot2) continue;
      if (height[rot1] > height[rot2])
        par[rot2] = rot1;
      else {
        if (height[rot1] == height[rot2]) height[rot2] += 1;
        par[rot1] = rot2;
      }
      ans += kk.first.first;
      if (u == 1 || v == 1) {
        vec.push_back({1, kk.first.second});
        x++;
      } else
        vec.push_back({10, kk.first.second});
    }
    sort(vec.begin(), vec.end());
    if (x == k) {
      printf("%lld\n", n - 1);
      for (long long i = 0; i < n - 1; i++) cout << vec[i].second + 1 << " ";
      cout << endl;
      mid1 = mid;
      return 0;
    }
    for (long long i = 0; i < m; i++) {
      if (me[i].second.first == 1 || me[i].second.second == 1) {
        me[i].first.first -= mid;
      }
    }
  }
  if (x != k) printf("-1\n");
}