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;
struct Edge {
  int u, v, w;
};
Edge edge[100005], dp[5005];
bool road[5005][5005];
int n, m, k;
int w[5005][5005];
int sign[5005][5005];
int p[5005];
int mi[5005], to[5005], from[5005];
int ans_print[100005];
void init() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      w[i][j] = -1;
      road[i][j] = 0;
    }
  }
}
int find1(int x) {
  if (p[x] == x) {
    return x;
  }
  return p[x] = find1(p[x]);
}
bool cmp(Edge t1, Edge t2) { return t1.w < t2.w; }
int kruscal() {
  sort(edge + 1, edge + 1 + m, cmp);
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    int u = edge[i].u;
    int v = edge[i].v;
    int cost = edge[i].w;
    if (u != 1 && v != 1) {
      int t1 = find1(u);
      int t2 = find1(v);
      if (t1 != t2) {
        ans += cost;
        p[t1] = t2;
        road[u][v] = road[v][u] = 1;
      }
    }
  }
  return ans;
}
void dfs(int cur, int pre) {
  for (int i = 2; i <= n; i++) {
    if (i != pre && road[cur][i] == 1) {
      if (dp[i].w != -1) {
        if (w[cur][i] > dp[cur].w) {
          dp[i].u = cur;
          dp[i].v = i;
          dp[i].w = w[cur][i];
        } else {
          dp[i] = dp[cur];
        }
      }
      dfs(i, cur);
    }
  }
}
int main() {
  while (~scanf("%d%d%d", &n, &m, &k)) {
    init();
    int cnt1 = 0;
    for (int i = 1; i <= m; i++) {
      int u, v, cost;
      scanf("%d%d%d", &u, &v, &cost);
      edge[i].u = u;
      edge[i].v = v;
      edge[i].w = cost;
      w[u][v] = w[v][u] = cost;
      if (u == 1 || v == 1) {
        cnt1++;
      }
      sign[u][v] = sign[v][u] = i;
    }
    if (cnt1 < k) {
      printf("-1\n");
      continue;
    }
    int ans = kruscal();
    memset(mi, 0x3f3f3f3f, sizeof(mi));
    for (int i = 2; i <= n; i++) {
      p[i] = find1(i);
    }
    for (int i = 1; i <= m; i++) {
      int u = edge[i].u;
      int v = edge[i].v;
      int cost = edge[i].w;
      if (u > v) {
        swap(u, v);
      }
      if (u == 1) {
        int t1 = find1(v);
        if (cost < mi[t1]) {
          mi[t1] = cost;
          to[t1] = v;
        }
      }
    }
    int num = 0;
    for (int i = 2; i <= n; i++) {
      int t1 = find1(i);
      if (mi[t1]) {
        ans += mi[t1];
        mi[t1] = 0;
        road[1][to[t1]] = road[to[t1]][1] = 1;
        num++;
      }
    }
    if (num > k) {
      printf("-1\n");
      continue;
    }
    int ki = num;
    for (ki = ki + 1; ki <= k; ki++) {
      dp[1].w = -1;
      for (int v = 2; v <= n; v++) {
        if (road[1][v])
          dp[v].w = -1;
        else
          dp[v].w = 0;
      }
      dfs(1, 0);
      int to, mi = 0x3f3f3f3f;
      for (int v = 2; v <= n; v++) {
        if (w[1][v] == -1 || dp[v].w == -1) continue;
        if (mi > w[1][v] - dp[v].w) mi = w[1][v] - dp[v].w, to = v;
      }
      road[1][to] = road[to][1] = 1;
      road[dp[to].u][dp[to].v] = road[dp[to].v][dp[to].u] = 0;
      ans += mi;
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if (road[i][j] == 1 && w[i][j] != -1) {
          ans_print[sum++] = sign[i][j];
        }
      }
    }
    printf("%d\n", sum);
    for (int i = 0; i < sum; i++) {
      printf(i == sum - 1 ? "%d\n" : "%d ", ans_print[i]);
    }
  }
  return 0;
}