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 = 100010, M = 1000010, INF = 0x3f3f3f3f;
inline int Max(int x, int y) { return x > y ? x : y; }
inline int Min(int x, int y) { return x < y ? x : y; }
inline void Swap(int &x, int &y) { x ^= y ^= x ^= y; }
int head[N], ver[M], edge[M], Next[M], tot;
int n, m, k, t, v[N], d[N], fa[N], f[N][20], Tmax[N][20];
struct rec {
  int x, y, z, v, id;
} e[M];
queue<int> q;
bool cmp1(rec a, rec b) { return a.z < b.z; }
bool cmp2(rec a, rec b) { return a.id < b.id; }
void add(int x, int y, int z) {
  ver[++tot] = y, edge[tot] = z, Next[tot] = head[x], head[x] = tot;
}
int get(int x) {
  if (x == fa[x]) return x;
  return fa[x] = get(fa[x]);
}
void bfs() {
  d[1] = 1;
  q.push(1);
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = Next[i]) {
      int y = ver[i], z = edge[i];
      if (d[y]) continue;
      d[y] = d[x] + 1;
      f[y][0] = x;
      Tmax[y][0] = z;
      for (int j = 1; j <= t; j++) {
        f[y][j] = f[f[y][j - 1]][j - 1];
        Tmax[y][j] = Max(Tmax[y][j - 1], Tmax[f[y][j - 1]][j - 1]);
      }
      q.push(y);
    }
  }
}
int mxv(int x, int y) {
  int res = -INF;
  if (d[x] > d[y]) Swap(x, y);
  for (int i = t; i >= 0; i--)
    if (d[f[y][i]] >= d[x]) res = Max(res, Tmax[y][i]), y = f[y][i];
  if (x == y) return res;
  for (int i = t; i >= 0; i--)
    if (f[x][i] != f[y][i]) {
      res = Max(res, Tmax[x][i]);
      res = Max(res, Tmax[y][i]);
      x = f[x][i], y = f[y][i];
    }
  res = Max(res, Max(Tmax[x][0], Tmax[y][0]));
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  t = (int)(log(n) / log(2)) + 1;
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d", &e[i].x, &e[i].y, &e[i].z), e[i].id = i;
  sort(e + 1, e + m + 1, cmp1);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int x = get(e[i].x);
    int y = get(e[i].y);
    if (x == y) continue;
    fa[x] = y;
    e[i].v = ++k;
    add(e[i].x, e[i].y, e[i].z);
    add(e[i].y, e[i].x, e[i].z);
    if (k == n - 1) break;
  }
  bfs();
  sort(e + 1, e + m + 1, cmp2);
  for (int i = 1; i <= m; i++)
    if (!e[i].v) printf("%d\n", mxv(e[i].x, e[i].y));
  return 0;
}