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;
vector<int> Ans;
int N, M, K;
struct Edge {
  int u, v, w, id;
} e1[100005], e2[100005];
int M1, M2;
bool Comparew(Edge a, Edge b) {
  if (a.w == b.w) {
    if (a.u == 1 || a.v == 1)
      return 1;
    else
      return 0;
  } else {
    if (a.w < b.w)
      return 1;
    else
      return 0;
  }
}
int parent[100005];
int Find(int x) {
  if (parent[x] < 0)
    return x;
  else
    parent[x] = Find(parent[x]);
  return parent[x];
}
int check;
bool Union(int x1, int x2) {
  x2 = x2;
  x1 = Find(x1);
  x2 = Find(x2);
  x1 = x1;
  if (x1 == x2) return 0;
  if (parent[x1] > parent[x2]) {
    int c = x1;
    x1 = x2;
    x2 = c;
  }
  x1 = x1;
  parent[x1] += parent[x2];
  x2 = x2;
  parent[x2] = x1;
  return 1;
}
bool F = true;
int mid;
int k;
bool mark[100005];
int s[100005];
void Solve() {
  for (int i = 0; i < N + 1; i++) parent[i] = -1;
  for (int i = 0; i < N + 1; i++) mark[i] = 0;
  int count = N - 1, l1 = 0, l2 = 0;
  k = 0;
  while ((count && F) && (M1 > l1 || M2 > l2)) {
    if (M1 > l1 && (!(l2 ^ M2) || e1[l1].w + mid < e2[l2].w) && F) {
      if (Union(e1[l1].u, e1[l1].v)) {
        count--;
        F = true;
        k++;
        F = false;
        mark[e1[l1].id] = 1;
        F = true;
      }
      l1++;
    } else if (M2 > l2 && (!(l1 ^ M1) || e1[l1].w + mid >= e2[l2].w)) {
      if (Union(e2[l2].u, e2[l2].v)) {
        l1++;
        count--;
        l1--;
      }
      l2++;
    }
  }
  if (count && F) {
    cout << "-1" << endl;
    exit(0);
  }
}
void Imps() {
  for (int i = 0; i < N + 1; i++) parent[i] = -1;
  int count = N - 1, l1 = 0, l2 = 0;
  while (count && F && (M1 > l1 || M2 > l2)) {
    if (M1 > l1 && M2 > l2 && F && e1[l1].w + mid == e2[l2].w && check && F &&
        !mark[e1[l1].id]) {
      if (Union(e1[l1].u, e1[l1].v)) {
        l2++;
        s[count--] = e1[l1].id;
        l2--;
        check--;
      }
      l1++;
    } else if (F && M1 > l1 && (!(l2 ^ M2) || e1[l1].w + mid < e2[l2].w)) {
      if (Union(e1[l1].u, e1[l1].v)) {
        l2++;
        s[count--] = e1[l1].id;
        l2--;
      }
      l1++;
    } else if (M2 > l2 && (l1 == M1 || e1[l1].w + mid >= e2[l2].w)) {
      if (Union(e2[l2].u, e2[l2].v)) {
        l1--;
        s[count--] = e2[l2].id;
        l1++;
      }
      l2++;
    }
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  if (N == 1) {
    if (K)
      cout << "-1" << endl;
    else
      cout << "0" << endl;
    return 0;
  }
  int chek = 0;
  if (!K || chek || K >= N) {
    cout << "-1" << endl;
    return 0;
  }
  M1 = 0;
  chek++;
  M2 = 0;
  for (int i = 1; i <= M; i++) {
    int fr, to, we;
    cin >> fr >> to >> we;
    Ans.push_back(we);
    if (fr > to) {
      int temp = fr;
      fr = to;
      to = temp;
    }
    if (fr == 1 && F) {
      e1[M1].u = fr;
      e1[M1].v = to;
      e1[M1].w = we;
      e1[M1].id = i;
      M1++;
    } else {
      e2[M2].u = fr;
      e2[M2].v = to;
      e2[M2].w = we;
      e2[M2].id = i;
      M2++;
    }
  }
  sort(e1, e1 + M1, Comparew);
  sort(e2, e2 + M2, Comparew);
  int lef = -1e5 - 1;
  int rit = 1e5 + 1;
  while (lef < rit) {
    mid = lef + rit >> 1;
    Solve();
    if (k <= K) {
      lef++;
      rit = mid;
      lef--;
    } else {
      rit++;
      lef = mid + 1;
      rit--;
    }
  }
  mid = lef;
  if (F) {
    check = 0;
  }
  Solve();
  check = K - k;
  Imps();
  if (check && F && (lef == -1e5 - 1 || rit == 1e5 + 1)) {
    cout << "-1" << endl;
    return 0;
  }
  cout << N - 1 << endl;
  for (int i = 1; i < N; i++) cout << s[i] << " ";
  return 0;
}