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 cmp(int i, int j) { return c[i] < c[j]; }
struct Restricted_MST {
  int n, lmt;
  vector<pair<pair<int, int>, int> > e;
  int prt[MAXN];
  int to[MAXN], fe[MAXN], ne[MAXN];
  bool cs[MAXN];
  int bst[MAXN], bsc[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 find(int i) {
    if (prt[i] != i) prt[i] = find(prt[i]);
    return prt[i];
  }
  void push(int i, int u, int v) {
    to[i] = v;
    ne[i] = fe[u];
    fe[u] = i;
  }
  void dfs(int p, int u) {
    for (int i = fe[u]; i != -1; i = ne[i]) {
      if (!cs[i >> 1]) continue;
      int v = to[i];
      if (p == v) continue;
      if (u) {
        bst[v] = c[i >> 1];
        bsc[v] = i >> 1;
        if (bst[u] > bst[v]) {
          bst[v] = bst[u];
          bsc[v] = bsc[u];
        }
      } else
        bst[v] = -INF;
      dfs(u, v);
    }
  }
  void add(int i) {
    push(i + i, a[i], b[i]);
    push(i + i + 1, b[i], a[i]);
  }
  vector<int> ans;
  void solve() {
    ans.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, cmp);
    for (int i = int(0); i < int(n); ++i) prt[i] = i;
    memset(cs, 0, sizeof(cs));
    for (int i = int(0); i < int(m); ++i) {
      int p = order[i];
      if ((!a[p]) || (find(a[p]) == find(b[p]))) continue;
      cs[p] = true;
      prt[find(a[p])] = find(b[p]);
    }
    int x = 0;
    for (int i = int(1); i < int(n); ++i) {
      if (find(i) == i) {
        x += 1;
        bst[i] = INF;
      }
    }
    if (x > lmt) {
      ans.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 = find(b[i]);
      if (c[i] < bst[r]) {
        bst[r] = c[i];
        bsc[r] = i;
      }
    }
    for (int i = int(1); i < int(n); ++i) {
      if (find(i) == i) {
        if (bst[i] == INF) {
          ans.push_back(-1);
          return;
        }
        cs[bsc[i]] = true;
      }
    }
    memset(fe, -1, sizeof(fe));
    for (int i = int(0); i < int(m); ++i)
      if (cs[i]) add(i);
    while (x < lmt) {
      dfs(-1, 0);
      int tb = INF, tc;
      for (int i = int(1); i < int(n); ++i) {
        if ((adj[i] == -1) || (bst[i] == -INF)) continue;
        if ((c[adj[i]] - bst[i]) < tb) {
          tb = c[adj[i]] - bst[i];
          tc = i;
        }
      }
      if (tb == INF) {
        ans.push_back(-1);
        return;
      }
      cs[bsc[tc]] = false;
      cs[adj[tc]] = true;
      add(adj[tc]);
      x += 1;
    }
    for (int i = int(0); i < int(m); ++i)
      if (cs[i]) ans.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.ans.size() == 1) && (R.ans[0] == -1)) {
      printf("-1\n");
    } else {
      printf("%d\n", R.ans.size());
      for (int i = int(0); i < int(R.ans.size()); ++i) {
        if (i) printf(" ");
        printf("%d", R.ans[i] + 1);
      }
      printf("\n");
    }
  }
}