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, next, id;
};
int cnt;
int head[5005];
int n, m, k;
int p[5005];
int vis[5005];
int Max[5005];
int sign[100005];
int num;
int print[100005];
Edge edge[100005], edge_temp[100005], dp[5005];
void add(int u, int v, int w, int id) {
  edge[cnt].u = u;
  edge[cnt].v = v;
  edge[cnt].w = w;
  edge[cnt].id = id;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
bool cmp(Edge t1, Edge t2) { return t1.w < t2.w; }
int find1(int x) {
  if (p[x] == x) {
    return x;
  }
  return p[x] = find1(p[x]);
}
int kruscal() {
  int ans = 0;
  sort(edge_temp + 1, edge_temp + 1 + m, cmp);
  int temp_num = 0;
  for (int i = 1; i <= m; i++) {
    int u = edge_temp[i].u;
    int v = edge_temp[i].v;
    int w = edge_temp[i].w;
    int id = edge_temp[i].id;
    if (u != 1) {
      int t1 = find1(u);
      int t2 = find1(v);
      if (t1 != t2) {
        temp_num++;
        ans += w;
        p[t1] = t2;
        add(u, v, w, id);
        add(v, u, w, id);
        sign[id] = 1;
      }
    }
  }
  return ans;
}
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline void read(int &x) {
  char ch;
  while (blank(ch = nc()))
    ;
  if (IOerror) return;
  for (x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0')
    ;
}
};  // namespace fastIO
void dfs(int cur, int pre) {
  for (int i = head[cur]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    int w = edge[i].w;
    int id = edge[i].id;
    if (v != pre && sign[id]) {
      if (dp[v].w != -1) {
        if (w > dp[cur].w) {
          dp[v].w = w;
          dp[v].u = cur;
          dp[v].v = v;
          dp[v].id = id;
        } else {
          dp[v] = dp[cur];
        }
      }
      dfs(v, cur);
    }
  }
}
int main() {
  fastIO::read(n);
  fastIO::read(m);
  fastIO::read(k);
  cnt = 0;
  int cnt1 = 0;
  for (int i = 1; i <= m; i++) {
    sign[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    head[i] = -1;
    p[i] = i;
    vis[i] = 0;
    Max[i] = 0x3f3f3f3f;
  }
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    fastIO::read(u);
    fastIO::read(v);
    fastIO::read(w);
    int temp = u ^ v;
    if (u > v) {
      u = temp ^ u;
      v = temp ^ u;
    }
    if (u == 1) {
      cnt1++;
    }
    edge_temp[i].u = u;
    edge_temp[i].v = v;
    edge_temp[i].w = w;
    edge_temp[i].id = i;
  }
  if (cnt1 < k) {
    printf("-1\n");
    return 0;
    ;
  }
  int ans = kruscal();
  int k_temp = 0;
  for (int i = 1; i <= m; i++) {
    int u = edge_temp[i].u;
    int v = edge_temp[i].v;
    int w = edge_temp[i].w;
    int id = edge_temp[i].id;
    int t1 = find1(v);
    if (u == 1 && vis[t1] == 0) {
      add(u, v, w, id);
      dp[v].w = -1;
      Max[v] = -1;
      k_temp++;
      ans += w;
      vis[t1] = 1;
      sign[id] = 1;
    }
  }
  if (k_temp > k) {
    printf("-1\n");
    return 0;
    ;
  }
  for (int i = k_temp + 1; i <= k; i++) {
    for (int j = 2; j <= n; j++) {
      if (Max[j] == -1) {
        dp[j].w = -1;
      } else {
        dp[j].w = 0;
      }
    }
    dfs(1, -1);
    int Min = 0x3f3f3f3f;
    int pos;
    int pos_temp;
    for (int j = 1; j <= m; j++) {
      int u = edge_temp[j].u;
      int v = edge_temp[j].v;
      int w = edge_temp[j].w;
      int id = edge_temp[j].id;
      if (u == 1 && dp[v].w != -1) {
        if (Min > w - dp[v].w) {
          Min = w - dp[v].w;
          pos = v;
          pos_temp = id;
        }
      }
    }
    sign[pos_temp] = 1;
    sign[dp[pos].id] = 0;
    Max[pos] = -1;
    ans += Min;
    add(1, pos, 0, pos_temp);
  }
  for (int i = 1; i <= m; i++) {
    if (sign[i]) {
      print[num++] = i;
    }
  }
  printf("%d\n", num);
  for (int i = 0; i < num; i++) {
    printf(i == num - 1 ? "%d\n" : "%d ", print[i]);
  }
  return 0;
}