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 MAXN = 5000;
const int MAXM = 100000;
const int INF = 0x3f3f3f3f;
template <class T>
void Read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = 0;
  while (c < '0' || '9' < c) {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (flag) x = -x;
}
struct node {
  int v, w, id;
  bool vis;
  node *bck, *nxt;
} * adj[MAXN + 10], Edges[MAXM * 2 + 10], *New = Edges, *zero = Edges;
void addedges(int u, int v, int w, int id) {
  node *p = ++New;
  p->v = v;
  p->w = w;
  p->id = id;
  p->vis = false;
  p->bck = New + 1;
  p->nxt = adj[u];
  adj[u] = p;
  p = ++New;
  p->v = u;
  p->w = w;
  p->id = id;
  p->vis = false;
  p->bck = New - 1;
  p->nxt = adj[v];
  adj[v] = p;
}
int u[MAXM + 10], v[MAXM + 10], w[MAXM + 10];
bool used[MAXM + 10];
int dist[MAXN + 10], id[MAXN + 10];
int n, m, k;
bool cmp(const int &a, const int &b) { return w[a] < w[b]; }
int rt[MAXN + 10];
inline int find(int x) { return rt[x] == x ? x : rt[x] = find(rt[x]); }
inline bool merge(int a, int b) {
  int rt1 = find(a), rt2 = find(b);
  if (rt1 == rt2)
    return false;
  else {
    rt[rt1] = rt2;
    return true;
  }
}
int pos[MAXM + 10];
void kruskal_o1() {
  int res = n - 1;
  for (int i = 1; i <= m; ++i) {
    if (u[pos[i]] == 1 || v[pos[i]] == 1) continue;
    if (merge(u[pos[i]], v[pos[i]])) {
      addedges(u[pos[i]], v[pos[i]], w[pos[i]], pos[i]);
      if (--res == 1) break;
    }
  }
}
vector<int> ans;
bool vis[MAXN + 10];
int val[MAXN + 10];
node *pre[MAXN + 10];
void dfs(int x, int f, int mxv, node *&mxid) {
  val[x] = mxv, pre[x] = mxid;
  for (node *p = adj[x]; p != NULL; p = p->nxt) {
    if (p->v == f || p->vis) continue;
    dfs(p->v, x, max(mxv, p->w), p->w > mxid->w ? p : mxid);
  }
}
void getans(int x, int f) {
  for (node *p = adj[x]; p != NULL; p = p->nxt) {
    if (p->v == f || p->vis) continue;
    ans.push_back(p->id);
    getans(p->v, x);
  }
}
int main() {
  Read(n), Read(m), Read(k);
  memset(dist, 0x3f, sizeof(dist));
  for (int i = 1; i <= m; ++i) Read(u[i]), Read(v[i]), Read(w[i]);
  for (int i = 1; i <= m; ++i) pos[i] = i;
  sort(pos + 1, pos + m + 1, cmp);
  for (int i = 1; i <= n; ++i) rt[i] = i;
  kruskal_o1();
  int d = 0;
  for (int i = 1; i <= m && d < k; ++i)
    if (u[pos[i]] == 1 || v[pos[i]] == 1) {
      int t = u[pos[i]] + v[pos[i]] - 1;
      if (1 == find(t)) continue;
      rt[find(t)] = 1;
      used[pos[i]] = true;
      vis[t] = true;
      addedges(1, t, w[pos[i]], pos[i]);
      ++d;
    }
  for (int i = 1; i <= m; ++i) {
    if (used[i]) continue;
    if (u[i] == 1) dist[v[i]] = min(dist[v[i]], w[i]), id[v[i]] = i;
    if (v[i] == 1) dist[u[i]] = min(dist[u[i]], w[i]), id[u[i]] = i;
  }
  for (int i = 2; i <= n; ++i)
    if (vis[i]) dfs(i, 1, 0, zero);
  while (d < k) {
    int p = 0, mnv = INF;
    for (int i = 2; i <= n; ++i)
      if (!vis[i] && mnv > dist[i] - val[i]) mnv = dist[i] - val[i], p = i;
    if (!p) break;
    if (pre[p]) pre[p]->vis = pre[p]->bck->vis = true;
    addedges(1, p, dist[p], id[p]);
    vis[p] = true;
    ++d;
    for (int i = 2; i <= n; ++i)
      if (vis[i]) dfs(i, 1, 0, zero);
  }
  int root = find(1);
  for (int i = 2; i <= n; ++i)
    if (find(i) != root) {
      puts("-1");
      return 0;
    }
  ans.clear();
  getans(1, 0);
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i)
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
}