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;
struct edge {
  int s, t, d, i;
  bool operator<(const edge& y) const { return d < y.d; }
} e[100005 * 10];
int n, m, M, i, j, k, f[100005], F[100005][20], G[100005][20], d[100005],
    h[100005], ne[100005 << 1], p[100005 << 1], w[100005 << 1], u[100005 * 10],
    v[100005 * 10];
bool b[100005 * 10];
int get(int x) {
  if (f[x] == x) return x;
  return f[x] = get(f[x]);
}
void dfs(int x) {
  int i;
  for (i = 1; 1 << i <= d[x]; i++) {
    F[x][i] = F[F[x][i - 1]][i - 1];
    G[x][i] = max(G[x][i - 1], G[F[x][i - 1]][i - 1]);
  }
  for (i = h[x]; i; i = ne[i])
    if (p[i] != f[x]) {
      f[p[i]] = F[p[i]][0] = x;
      G[p[i]][0] = w[i];
      d[p[i]] = d[x] + 1;
      dfs(p[i]);
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &e[i].s, &e[i].t, &e[i].d);
    u[i] = e[i].s;
    v[i] = e[i].t;
    e[i].i = i;
  }
  sort(e + 1, e + m + 1);
  for (i = 1; i <= n; i++) f[i] = i;
  for (i = 1; i <= m; i++)
    if (get(e[i].s) != get(e[i].t)) {
      f[get(e[i].s)] = get(e[i].t);
      p[++M] = e[i].t;
      ne[M] = h[e[i].s];
      h[e[i].s] = M;
      w[M] = e[i].d;
      p[++M] = e[i].s;
      ne[M] = h[e[i].t];
      h[e[i].t] = M;
      w[M] = e[i].d;
    } else
      b[e[i].i] = 1;
  f[1] = 0;
  dfs(1);
  for (i = 1; i <= m; i++)
    if (b[i]) {
      k = 0;
      if (d[u[i]] < d[v[i]]) swap(u[i], v[i]);
      if (d[u[i]] != d[v[i]])
        for (j = 19; ~j; j--)
          if (d[u[i]] - d[v[i]] >> j & 1) {
            k = max(k, G[u[i]][j]);
            u[i] = F[u[i]][j];
          }
      if (u[i] != v[i]) {
        for (j = 19; ~j; j--)
          if (F[u[i]][j] != F[v[i]][j]) {
            k = max(k, max(G[u[i]][j], G[v[i]][j]));
            u[i] = F[u[i]][j];
            v[i] = F[v[i]][j];
          }
        k = max(k, max(G[u[i]][0], G[v[i]][0]));
      }
      printf("%d\n", k);
    }
  return 0;
}