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 + 10;
const int maxm = 100000 + 10;
struct edge {
  int a, b, c;
};
int n, m, k;
edge e[maxm];
int c1[maxn], min1[maxn];
int num[maxm];
int belong[maxn], my_edge[maxn];
vector<pair<int, int> > tree[maxn];
int hsize, pos[maxn], ind[maxn], max1[maxn];
bool cut[maxm];
void NoAnswer() {
  puts("-1");
  exit(0);
}
inline bool cmp(const int &a, const int &b) { return e[a].c < e[b].c; }
int get_belong(int x) {
  return x == belong[x] ? x : belong[x] = get_belong(belong[x]);
}
inline int val(int x) {
  x = ind[x];
  return e[c1[x]].c - e[max1[x]].c;
}
void up(int i) {
  while (i > 1) {
    int j = i / 2;
    if (val(i) < val(j)) {
      swap(ind[i], ind[j]);
      pos[ind[i]] = i;
      pos[ind[j]] = j;
      i = j;
    } else
      break;
  }
}
void down(int i) {
  while (i <= hsize / 2) {
    int j = i * 2;
    if (j < hsize && val(j + 1) < val(j)) ++j;
    if (val(j) < val(i)) {
      swap(ind[i], ind[j]);
      pos[ind[i]] = i;
      pos[ind[j]] = j;
      i = j;
    } else
      break;
  }
}
inline void change(int x, int r) {
  max1[x] = r;
  up(pos[x]);
  down(pos[x]);
}
void update(int x, int papa = 0, int r = 0) {
  if (c1[x]) change(x, r);
  for (int i = 0; i < tree[x].size(); ++i)
    if (!cut[tree[x][i].second] && tree[x][i].first != papa) {
      my_edge[tree[x][i].first] = tree[x][i].second;
      if (e[tree[x][i].second].c > e[r].c)
        update(tree[x][i].first, x, tree[x][i].second);
      else
        update(tree[x][i].first, x, r);
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n == 1) {
    if (k) NoAnswer();
    puts("0");
    puts("");
    exit(0);
  }
  if (k == 0) NoAnswer();
  e[0].c = -5000000;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &e[i].a, &e[i].b, &e[i].c);
    if (e[i].a > e[i].b) swap(e[i].a, e[i].b);
    if (e[i].a == 1) c1[e[i].b] = i;
  }
  for (int i = 1; i <= m; ++i) num[i] = i;
  sort(num + 1, num + m + 1, cmp);
  for (int i = 1; i <= n; ++i) belong[i] = i;
  for (int i = 1; i <= m; ++i)
    if (e[num[i]].a != 1) {
      int p = get_belong(e[num[i]].a), q = get_belong(e[num[i]].b);
      if (p != q) {
        belong[p] = q;
        tree[e[num[i]].a].push_back(make_pair(e[num[i]].b, num[i]));
        tree[e[num[i]].b].push_back(make_pair(e[num[i]].a, num[i]));
      }
    }
  hsize = 0;
  for (int i = 1; i <= n; ++i)
    if (c1[i]) {
      pos[i] = ++hsize;
      ind[hsize] = i;
    }
  for (int i = 1; i <= n; ++i) belong[i] = get_belong(i);
  for (int i = 1; i <= m; ++i)
    if (e[i].a == 1)
      if (min1[belong[e[i].b]] == 0 || e[i].c < e[min1[belong[e[i].b]]].c)
        min1[belong[e[i].b]] = i;
  for (int i = 2; i <= n; ++i)
    if (min1[i]) {
      --k;
      my_edge[e[min1[i]].b] = min1[i];
      update(e[min1[i]].b);
    }
  if (k < 0) NoAnswer();
  while (k--) {
    if (max1[ind[1]] == 0) NoAnswer();
    cut[max1[ind[1]]] = true;
    my_edge[ind[1]] = c1[ind[1]];
    update(ind[1]);
  }
  printf("%d\n", n - 1);
  for (int i = 2; i <= n; ++i) printf("%d ", my_edge[i]);
  printf("\n");
  return 0;
}