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 = 2e5 + 5;
const int M = 1e6 + 5;
const int step = 18;
int n, m, q, p[N];
int cnt, head[N], dep[N], father[N][step + 1], b[N][step + 1], ans[M];
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int find(int x) {
  if (p[x] != x) p[x] = find(p[x]);
  return p[x];
}
struct edge {
  int to, next, dis;
} e[N << 1];
inline void add_edge(int u, int v, int d) {
  cnt++;
  e[cnt].dis = d;
  e[cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
inline void dfs(int u, int f) {
  dep[u] = dep[f] + 1;
  father[u][0] = f;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == f) continue;
    b[v][0] = e[i].dis;
    dfs(v, u);
  }
}
inline int ask(int x, int y) {
  int ans = 0;
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 0; i < step + 1; i++)
    if ((1 << i) & (dep[x] - dep[y])) {
      ans = max(ans, b[x][i]);
      x = father[x][i];
    }
  if (x == y) return ans;
  for (int i = step; i >= 0; i--) {
    if (father[x][i] != father[y][i]) {
      ans = max(ans, max(b[x][i], b[y][i]));
      x = father[x][i];
      y = father[y][i];
    }
  }
  return max(ans, max(b[x][0], b[y][0]));
}
struct node {
  int u, v, d, id;
  bool fg;
} a[M];
bool cmp(node a, node b) { return a.d < b.d; }
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= m; i++) {
    a[i].u = read();
    a[i].v = read();
    a[i].d = read();
    a[i].id = i;
  }
  sort(a + 1, a + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int u = a[i].u, v = a[i].v, d = a[i].d;
    if (find(u) != find(v)) {
      add_edge(u, v, d);
      add_edge(v, u, d);
      p[find(u)] = p[v];
      a[i].fg = 1;
    }
  }
  dfs(1, 0);
  for (int i = 1; i <= step; i++) {
    for (int j = 1; j <= n; j++) {
      father[j][i] = father[father[j][i - 1]][i - 1];
      b[j][i] = max(b[j][i - 1], b[father[j][i - 1]][i - 1]);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (a[i].fg == 0) {
      int x = a[i].u, y = a[i].v;
      ans[a[i].id] = ask(x, y);
    }
  }
  for (int i = 1; i <= m; i++) {
    if (ans[i] > 0) printf("%d ", ans[i]);
  }
  return 0;
}