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 = 200005;
int n, m, tot, sd[N * 2], a[N * 2], Ans[N * 5], in[N * 2], l, out[N * 2],
    fa[20][N * 2], f[N * 2], fi[N * 2], ne[N * 2], zz[N * 2];
struct Ask {
  int x, y, z, from;
} A[N * 5];
void jb(int x, int y) {
  ne[++tot] = fi[x];
  fi[x] = tot;
  zz[tot] = y;
}
int pd(int x, int y) {
  if (!x) return 1;
  return in[x] <= in[y] && out[x] >= out[y];
}
void dfs(int x, int y, int z) {
  fa[0][x] = y;
  in[x] = ++l;
  sd[x] = z;
  for (int i = fi[x]; i; i = ne[i])
    if (zz[i] != x) dfs(zz[i], x, z + 1);
  out[x] = ++l;
}
int cmp(Ask x, Ask y) { return x.z < y.z; }
int find(int x) {
  if (x == f[x]) return x;
  return f[x] = find(f[x]);
}
int lca(int x, int y) {
  if (x == y) return x;
  if (sd[x] < sd[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (!pd(fa[i][x], y)) x = fa[i][x];
  return fa[0][x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &A[i].x, &A[i].y, &A[i].z);
    A[i].from = i;
  }
  sort(A + 1, A + m + 1, cmp);
  int cnt = n;
  for (int i = 1; i < 2 * n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    int x = find(A[i].x), y = find(A[i].y);
    if (x != y) {
      f[x] = f[y] = f[++cnt];
      a[cnt] = A[i].z;
      jb(cnt, x);
      jb(cnt, y);
      A[i].from = 0;
    }
  }
  dfs(cnt, 0, 0);
  for (int i = 1; i <= 19; i++)
    for (int j = 1; j < n * 2; j++) fa[i][j] = fa[i - 1][fa[i - 1][j]];
  for (int i = 1; i <= m; i++)
    if (A[i].from) Ans[A[i].from] = a[lca(A[i].x, A[i].y)];
  for (int i = 1; i <= m; i++)
    if (Ans[i]) printf("%d\n", Ans[i]);
  return 0;
}