Problem: After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used according to the current Daleks' plan – which is to use a minimum spanning tree of Corridors. Heidi knows that all energy requirements for different Corridors are now different, and that the Daleks have a single unique plan which they are intending to use.

Your task is to calculate the number E_{max}(c), which is defined in the same way as in the easy version – i.e., the largest e ≤ 10^9 such that if we changed the energy of corridor c to e, the Daleks might use it – but now for every corridor that Heidi considers. 

Input

The first line: number n of destinations, number m of Time Corridors (2 ≤ n ≤ 10^5, n - 1 ≤ m ≤ 10^6). The next m lines: destinations a, b and energy e (1 ≤ a, b ≤ n, a ≠ b, 0 ≤ e ≤ 10^9).

No pair \\{a, b\} will repeat. The graph is guaranteed to be connected. All energy requirements e are distinct.

Output

Output m-(n-1) lines, each containing one integer: E_{max}(c_i) for the i-th Corridor c_i from the input that is not part of the current Daleks' plan (minimum spanning tree).

Example

Input

3 3
1 2 8
2 3 3
3 1 4


Output

4

Note

If m = n-1, then you need not output anything.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, m;
struct edge {
  int id, u, v, w;
  edge(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {}
  bool operator<(const edge b) const { return w < b.w; }
} e[N], e2[N];
int cur;
bool cmp(const edge a, const edge b) { return a.id < b.id; }
int fa[N], itt[N], sz[N];
inline int find(int x) { return x == fa[x] ? fa[x] : fa[x] = find(fa[x]); }
inline void merge(int x, int y) {
  int u = find(x), v = find(y);
  if (u == v) return;
  fa[u] = v;
}
bool ch[N];
inline void setup() {
  for (int i = 1; i <= n; i++) fa[i] = i, itt[i] = i;
}
vector<int> node[N];
vector<edge> qry[N];
int ans[N];
inline void merge2(int u, int v, int e_val) {
  int d1 = find(u), d2 = find(v);
  if (sz[d1] > sz[d2]) swap(d1, d2);
  for (size_t t = 0; t < node[d1].size(); t++) {
    int nd = node[d1][t];
    for (size_t i = 0; i < qry[nd].size(); i++) {
      edge e = qry[nd][i];
      int X = find(e.u), Y = find(e.v);
      if ((X == d2 && Y == d1) || (X == d1 && Y == d2)) {
        ans[e.id] = e_val;
      }
    }
    if (qry[nd].size()) node[d2].push_back(nd);
  }
  fa[d1] = d2;
  sz[d2] += sz[d1];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
    e[i].id = i;
  }
  sort(e + 1, e + m + 1);
  setup();
  for (int i = 1; i <= m; i++) {
    if (find(e[i].u) != find(e[i].v)) {
      ans[e[i].id] = -1;
      e2[++cur] = e[i];
      ch[e[i].id] = 1;
      merge(e[i].u, e[i].v);
    } else {
      qry[e[i].u].push_back(e[i]);
      qry[e[i].v].push_back(e[i]);
      sz[e[i].u]++, sz[e[i].v]++;
    }
  }
  setup();
  for (int i = 1; i <= n; i++) node[i].push_back(i);
  for (int i = 1; i < n; i++) {
    merge2(e2[i].u, e2[i].v, e2[i].w);
  }
  for (int i = 1; i <= m; i++) {
    if (ans[i] != -1) printf("%d\n", ans[i]);
  }
}