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;
template <typename T>
inline bool chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline T geti() {
  register T xi = 0;
  register char ch = getchar();
  bool f = 0;
  while (!isdigit(ch)) ch == '-' ? f = 1 : f, ch = getchar();
  while (isdigit(ch)) xi = xi * 10 + ch - 48, ch = getchar();
  return f ? -xi : xi;
}
template <typename T>
inline void pi(T k, char ch = 0) {
  if (k < 0) k = -k, putchar('-');
  if (k >= 10) pi(k / 10);
  putchar(k % 10 + '0');
  if (ch) putchar(ch);
}
const int N = 1e4 + 7, M = 1e5 + 7;
struct edge {
  int u, v, w, id;
  bool operator<(const edge &b) const { return w == b.w ? u < b.u : w < b.w; }
} e[M];
vector<edge> G[N];
int edgecnt;
int fa[N], rk[N];
bitset<100001> vis;
int n, m, k, cnt;
inline void clear() {
  for (int i = 1; i <= n; ++i) fa[i] = i;
  fill(rk, rk + N, 1);
}
inline int find(int x) { return fa[x] == x ? x : (fa[x] = find(fa[x])); }
inline bool merge(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  if (rk[x] > rk[y]) swap(x, y);
  fa[x] = y, rk[y] += rk[x];
  return 1;
}
inline bool check() {
  clear();
  int deg = 0;
  for (int i = 1; i <= m; ++i)
    if (e[i].u != 1)
      merge(e[i].u, e[i].v);
    else
      ++deg;
  if (deg < k) return 0;
  cnt = 0;
  for (int i = 2; i <= n; ++i)
    if (find(i) == i) ++cnt;
  if (cnt > k) return 0;
  for (int i = 1; i <= m; ++i)
    if (e[i].u == 1) merge(e[i].u, e[i].v);
  cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (find(i) == i) ++cnt;
  return cnt == 1;
}
inline void dfs(int x, int p) {
  fa[x] = fa[p];
  for (auto &&i : G[x])
    if (i.v ^ p) dfs(i.v, x);
}
int val[N], id[N];
set<int> print;
int main(void) {
  n = geti<int>(), m = geti<int>(), k = geti<int>();
  if (n == 1) return pi(0), 0;
  int maxw = 0;
  for (int i = 1; i <= m; ++i) {
    e[i] = (edge){geti<int>(), geti<int>(), geti<int>(), i};
    if (e[i].u > e[i].v) swap(e[i].u, e[i].v);
    chkmax(maxw, e[i].w);
  }
  sort(e + 1, e + m + 1);
  if (!check()) return pi(-1), 0;
  int l = -maxw, r = maxw, ans = 998244353;
  while (l <= r) {
    int mid = (l + r) >> 1;
    clear();
    for (int i = 1; i <= m; ++i)
      if (e[i].u == 1) e[i].w += mid;
    sort(e + 1, e + m + 1);
    cnt = 0;
    for (int i = 1, tot = 0; i <= m; ++i)
      if (merge(e[i].u, e[i].v)) {
        ++tot;
        if (e[i].u == 1) ++cnt;
        if (tot == n - 1) break;
      }
    for (int i = 1; i <= m; ++i)
      if (e[i].u == 1) e[i].w -= mid;
    if (cnt >= k)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  clear(), cnt = 0;
  for (int i = 1; i <= m; ++i)
    if (e[i].u == 1) e[i].w += ans;
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= m; ++i)
    if (merge(e[i].u, e[i].v)) {
      vis.set(i);
      if (e[i].u == 1) ++cnt;
      print.insert(e[i].id);
      G[e[i].u].push_back((edge){0, e[i].v, e[i].w, e[i].id});
      G[e[i].v].push_back((edge){0, e[i].u, e[i].w, e[i].id});
    }
  for (auto &&i : G[1]) {
    val[i.v] = i.w, id[i.v] = i.id;
    fa[1] = i.v, dfs(i.v, 1);
  }
  for (int i = 1; i <= m && cnt > k; ++i) {
    if (e[i].u != 1 && !vis[i]) {
      int u = find(e[i].u), v = find(e[i].v);
      if (u == v) continue;
      if (val[u] != e[i].w && val[v] != e[i].w) continue;
      if (val[v] == e[i].w) swap(u, v);
      fa[u] = v, --cnt;
      print.insert(e[i].id), print.erase(id[u]);
    }
  }
  if (cnt == k) {
    pi(n - 1, '\n');
    for (auto i : print) pi(i, ' ');
  } else
    pi(-1);
  return 0;
}