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;
#pragma comment(linker, "/STACK:102400000,102400000")
const int MAXN = 200005;
const int INF = 1050000000;
int c[MAXN];
bool compare(int i, int j) { return c[i] < c[j]; }
struct Restricted_MST {
  int n, lmt;
  vector<pair<pair<int, int>, int> > e;
  int parent[MAXN];
  int to[MAXN], firstEdge[MAXN], nextEdge[MAXN];
  bool choose[MAXN];
  int best[MAXN], candidate[MAXN];
  int a[MAXN], b[MAXN];
  int order[MAXN];
  int adj[MAXN];
  void init(int nn, int limit) {
    n = nn;
    lmt = limit;
    e.clear();
  }
  void addedge(int u, int v, int w) {
    e.push_back(make_pair(make_pair(u, v), w));
  }
  int findRoot(int i) {
    if (parent[i] != i) parent[i] = findRoot(parent[i]);
    return parent[i];
  }
  void addEdge(int i, int u, int v) {
    to[i] = v;
    nextEdge[i] = firstEdge[u];
    firstEdge[u] = i;
  }
  void dfs(int p, int u) {
    for (int i = firstEdge[u]; i != -1; i = nextEdge[i]) {
      if (!choose[i >> 1]) continue;
      int v = to[i];
      if (p == v) continue;
      if (u) {
        best[v] = c[i >> 1];
        candidate[v] = i >> 1;
        if (best[u] > best[v]) {
          best[v] = best[u];
          candidate[v] = candidate[u];
        }
      } else
        best[v] = -INF;
      dfs(u, v);
    }
  }
  void myAddEdge(int i) {
    addEdge(i + i, a[i], b[i]);
    addEdge(i + i + 1, b[i], a[i]);
  }
  vector<int> result;
  void solve() {
    result.clear();
    int m = e.size();
    for (int i = int(0); i < int(m); ++i) {
      a[i] = e[i].first.first;
      b[i] = e[i].first.second;
      c[i] = e[i].second;
      if (a[i] > b[i]) swap(a[i], b[i]);
      order[i] = i;
    }
    sort(order, order + m, compare);
    for (int i = int(0); i < int(n); ++i) parent[i] = i;
    memset(choose, 0, sizeof(choose));
    for (int i = int(0); i < int(m); ++i) {
      int p = order[i];
      if ((!a[p]) || (findRoot(a[p]) == findRoot(b[p]))) continue;
      choose[p] = true;
      parent[findRoot(a[p])] = findRoot(b[p]);
    }
    int component = 0;
    for (int i = int(1); i < int(n); ++i) {
      if (findRoot(i) == i) {
        component += 1;
        best[i] = INF;
      }
    }
    if (component > lmt) {
      result.push_back(-1);
      return;
    }
    memset(adj, -1, sizeof(adj));
    for (int i = int(0); i < int(m); ++i) {
      if (a[i]) continue;
      adj[b[i]] = i;
      int r = findRoot(b[i]);
      if (c[i] < best[r]) {
        best[r] = c[i];
        candidate[r] = i;
      }
    }
    for (int i = int(1); i < int(n); ++i) {
      if (findRoot(i) == i) {
        if (best[i] == INF) {
          result.push_back(-1);
          return;
        }
        choose[candidate[i]] = true;
      }
    }
    memset(firstEdge, -1, sizeof(firstEdge));
    for (int i = int(0); i < int(m); ++i)
      if (choose[i]) myAddEdge(i);
    while (component < lmt) {
      dfs(-1, 0);
      int tmpBest = INF, tmpCandidate;
      for (int i = int(1); i < int(n); ++i) {
        if ((adj[i] == -1) || (best[i] == -INF)) continue;
        if ((c[adj[i]] - best[i]) < tmpBest) {
          tmpBest = c[adj[i]] - best[i];
          tmpCandidate = i;
        }
      }
      if (tmpBest == INF) {
        result.push_back(-1);
        return;
      }
      choose[candidate[tmpCandidate]] = false;
      choose[adj[tmpCandidate]] = true;
      myAddEdge(adj[tmpCandidate]);
      component += 1;
    }
    for (int i = int(0); i < int(m); ++i)
      if (choose[i]) result.push_back(i);
  }
} R;
int main() {
  int n, m, lmt;
  while (scanf("%d%d%d", &n, &m, &lmt) == 3) {
    R.init(n, lmt);
    for (int i = int(0); i < int(m); ++i) {
      int u, v, w;
      scanf("%d%d%d", &u, &v, &w);
      R.addedge(u - 1, v - 1, w);
    }
    R.solve();
    if ((R.result.size() == 1) && (R.result[0] == -1)) {
      printf("-1\n");
    } else {
      printf("%d\n", R.result.size());
      for (int i = int(0); i < int(R.result.size()); ++i) {
        if (i) printf(" ");
        printf("%d", R.result[i] + 1);
      }
      printf("\n");
    }
  }
}