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, id;
  static bool SortByWeight(const Edge& lhs, const Edge& rhs) {
    return lhs.w < rhs.w;
  }
};
struct sigEdge {
  int v, w, id;
};
class disjointSet {
  const static int MAXN = 5000 + 5;
  int fa[MAXN];

 public:
  disjointSet() {
    for (int i = 0; i < MAXN; i++) fa[i] = i;
  }
  int find(int x) {
    if (x == fa[x]) return x;
    return fa[x] = find(fa[x]);
  }
  void unite(int x, int y) { fa[find(x)] = find(y); }
};
const int MAXN = 5000 + 10;
const int INF = 0x7F7F7F7F;
disjointSet dS, connectivityCheck;
int ans;
int N, M, K, connected;
vector<Edge> EdgeList;
Edge DP[MAXN];
vector<sigEdge> Adj[MAXN];
bool Forest[MAXN][MAXN], has_Sol = true;
set<int> chosen;
void Kruskal() {
  sort(EdgeList.begin(), EdgeList.end(), Edge::SortByWeight);
  for (vector<Edge>::iterator itr = EdgeList.begin(); itr != EdgeList.end();
       itr++) {
    int& u = itr->u;
    int& v = itr->v;
    int& w = itr->w;
    if (dS.find(u) != dS.find(v)) {
      dS.unite(u, v);
      Forest[u][v] = true;
      Forest[v][u] = true;
      chosen.insert(itr->id);
    }
  }
}
void ExpandRootToBlk() {
  int chosenPoint[MAXN];
  int chosenEdge[MAXN];
  int chosenEdgeId[MAXN];
  memset(chosenEdge, 0x7f, sizeof chosenEdge);
  for (vector<sigEdge>::iterator itr = Adj[1].begin(); itr != Adj[1].end();
       itr++) {
    int& to = itr->v;
    int curBlk = dS.find(to);
    if (chosenEdge[curBlk] > itr->w) {
      chosenEdgeId[curBlk] = itr->id;
      chosenEdge[curBlk] = itr->w;
      chosenPoint[curBlk] = to;
    }
  }
  for (int i = 1; i <= N; i++) {
    if (chosenEdge[i] < 0x7f7f7f7f) {
      connected++;
      Forest[1][chosenPoint[i]] = true;
      Forest[chosenPoint[i]][1] = true;
      chosen.insert(chosenEdgeId[i]);
    }
  }
}
void DFS(int cur, int fa) {
  for (vector<sigEdge>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end();
       itr++) {
    int& t = itr->v;
    if (t == fa || !Forest[cur][t]) continue;
    if (DP[t].w == -1) {
      if (DP[cur].w > itr->w)
        DP[t] = DP[cur];
      else
        DP[t].u = cur, DP[t].v = t, DP[t].w = itr->w, DP[t].id = itr->id;
    }
    DFS(t, cur);
  }
}
void ExpandRootFinal() {
  if (connected > K) {
    has_Sol = false;
    return;
  }
  for (int i = connected + 1; i <= K; i++) {
    memset(DP, 0xFF, sizeof DP);
    DP[1].w = -INF;
    for (int j = 2; j <= N; j++)
      if (Forest[1][j]) DP[j].w = -INF;
    DFS(1, 0);
    int minid, minto, minAdd(INF);
    for (vector<sigEdge>::iterator itr = Adj[1].begin(); itr != Adj[1].end();
         itr++)
      if (minAdd > itr->w - DP[itr->v].w) {
        minAdd = itr->w - DP[itr->v].w;
        minto = itr->v;
        minid = itr->id;
      }
    Forest[minto][1] = Forest[1][minto] = 1;
    Forest[DP[minto].u][DP[minto].v] = 0;
    Forest[DP[minto].v][DP[minto].u] = 0;
    chosen.erase(DP[minto].id);
    chosen.insert(minid);
  }
}
int main() {
  int u, v, w;
  cin >> N >> M >> K;
  for (int i = 1; i <= M; i++) {
    cin >> u >> v >> w;
    Adj[u].push_back(sigEdge{v, w, i});
    Adj[v].push_back(sigEdge{u, w, i});
    connectivityCheck.unite(u, v);
    if (u == 1 || v == 1) continue;
    EdgeList.push_back(Edge{u, v, w, i});
  }
  for (int i = 1; i < N; i++)
    if (connectivityCheck.find(u) != connectivityCheck.find(v)) {
      has_Sol = false;
      break;
    }
  if (has_Sol) Kruskal(), ExpandRootToBlk(), ExpandRootFinal();
  if (has_Sol) {
    cout << chosen.size() << endl;
    copy(chosen.begin(), chosen.end(), ostream_iterator<int>(cout, " "));
  } else
    cout << -1 << endl;
  return 0;
}