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 N = 5005;
const int NE = 200010;
const int inf = 0x3f3f3f3f;
int f[N], r[N];
inline void makeset(void) {
  memset(r, 0, sizeof(r));
  memset(f, 255, sizeof(f));
}
int find(int x) {
  int fx, i;
  for (fx = x; ~f[fx]; fx = f[fx])
    ;
  while (x != fx) {
    i = f[x];
    f[x] = fx;
    x = i;
  }
  return fx;
}
int Union(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return -1;
  if (r[x] > r[y]) {
    f[y] = x;
    return x;
  } else {
    if (r[x] == r[y]) r[y]++;
    f[x] = y;
    return y;
  }
}
struct Edge {
  int u, v, w;
  void set(int u, int v, int w) {
    this->u = u;
    this->v = v;
    this->w = w;
  }
  bool operator<(const Edge& r) const { return w < r.w; }
};
struct Kruskal {
  vector<pair<int, int> > E[N];
  int result, part;
  vector<pair<int, int> > tree[N];
  void init(void) {
    for (int i = 0; i < N; i++) E[i].clear();
  }
  void addEdge(int u, int v, int w) {
    E[u].push_back(pair<int, int>(w, v));
    E[v].push_back(pair<int, int>(w, u));
  }
  void kruskal(int n) {
    static Edge ee[NE];
    result = 0;
    part = n;
    makeset();
    for (int i = 0; i < n; i++) tree[i].clear();
    int ne = 0;
    for (int i = 0; i < n; i++)
      for (vector<pair<int, int> >::iterator it = E[i].begin();
           it != E[i].end(); it++)
        if (it->second > i) ee[ne++].set(i, it->second, it->first);
    sort(ee, ee + ne);
    Edge e;
    for (int i = 0; i < ne; i++) {
      e = ee[i];
      if (~Union(e.u, e.v)) {
        result += e.w;
        part--;
        tree[e.u].push_back(pair<int, int>(e.w, e.v));
        tree[e.v].push_back(pair<int, int>(e.w, e.u));
      }
    }
  }
};
struct DCMST {
  int v0;
  vector<pair<int, int> > E0;
  Kruskal kr;
  vector<pair<int, int> > tmpE0;
  int result;
  int minResult;
  void init(int v0) {
    this->v0 = v0;
    E0.clear();
    kr.init();
  }
  void addEdge(int u, int v, int w) {
    if (u == v0 || v == v0)
      E0.push_back(pair<int, int>(w, u + v - v0));
    else
      kr.addEdge(u, v, w);
  }
  int dcmst(int n, int k) {
    if ((int)E0.size() < k) return result = -1;
    kr.kruskal(n);
    tmpE0.clear();
    result = kr.result;
    int part = 0;
    sort(E0.begin(), E0.end());
    for (vector<pair<int, int> >::iterator it = E0.begin(); it != E0.end();
         it++) {
      if (~Union(v0, it->second)) {
        kr.tree[v0].push_back(pair<int, int>(it->first, it->second));
        kr.tree[it->second].push_back(pair<int, int>(it->first, v0));
        part++;
        result += it->first;
      } else
        tmpE0.push_back(*it);
    }
    if (part != kr.part - 1 || part > k) return minResult = -1;
    minResult = result;
    for (int i = 0; i < k - part; i++) extend_degree();
    return minResult;
  }
  void extend_degree(void) {
    static bool vis[N];
    static Edge best[N];
    static queue<int> q;
    memset(best, 255, sizeof(best));
    memset(vis, 0, sizeof(vis));
    q.push(v0);
    vis[v0] = 1;
    int u, v, w;
    while (!q.empty()) {
      u = q.front();
      q.pop();
      for (vector<pair<int, int> >::iterator it = kr.tree[u].begin();
           it != kr.tree[u].end(); it++) {
        w = it->first;
        if (vis[v = it->second]) continue;
        vis[v] = 1;
        q.push(v);
        if (u != v0) {
          if (best[u].w > w)
            best[v] = best[u];
          else
            best[v].set(u, v, w);
        }
      }
    }
    int mmin = inf;
    pair<int, int> tgt;
    for (vector<pair<int, int> >::iterator it = tmpE0.begin();
         it != tmpE0.end(); it++)
      if (it->first - best[it->second].w < mmin) {
        mmin = it->first - best[it->second].w;
        tgt = *it;
      }
    kr.tree[v0].push_back(pair<int, int>(tgt.first, tgt.second));
    kr.tree[tgt.second].push_back(pair<int, int>(tgt.first, v0));
    Edge tt = best[tgt.second];
    kr.tree[tt.u].erase(remove(kr.tree[tt.u].begin(), kr.tree[tt.u].end(),
                               pair<int, int>(tt.w, tt.v)),
                        kr.tree[tt.u].end());
    kr.tree[tt.v].erase(remove(kr.tree[tt.v].begin(), kr.tree[tt.v].end(),
                               pair<int, int>(tt.w, tt.u)),
                        kr.tree[tt.v].end());
    tmpE0.erase(remove(tmpE0.begin(), tmpE0.end(), tgt), tmpE0.end());
    result += tgt.first - tt.w;
    if (result < minResult) minResult = result;
  }
} dm;
map<pair<int, int>, int> eID;
int main(void) {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  dm.init(0);
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    u--, v--;
    eID[pair<int, int>(u, v)] = i;
    eID[pair<int, int>(v, u)] = i;
    dm.addEdge(u, v, w);
  }
  dm.dcmst(n, k);
  if (k == 0) {
    printf("%d\n", -1 + (n == 1));
    return 0;
  }
  if (dm.result == -1) {
    puts("-1");
    return 0;
  }
  vector<int> res;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < (int)dm.kr.tree[i].size(); j++) {
      int u = i, v = dm.kr.tree[i][j].second;
      res.push_back(eID[pair<int, int>(u, v)]);
    }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  printf("%d\n", (int)res.size());
  for (vector<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d\n", *it);
  return 0;
}