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 = 1e5 + 5, M = 1e6 + 5, logN = 20;
namespace Fast_io {
template <typename T>
inline void read(T &x) {
  char ch;
  int f = 1;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') f = -1;
  x = ch - '0';
  while (ch = getchar(), isdigit(ch)) x = x * 10 + ch - '0';
  x *= f;
}
template <typename T>
inline void read(T &x, T &y) {
  read(x);
  read(y);
}
template <typename T>
inline void rite(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) rite(x / 10);
  putchar(x % 10 + '0');
  return;
}
template <typename T>
inline void write(T x, char ch = '\n') {
  rite(x);
  putchar(ch);
  return;
}
}  // namespace Fast_io
using namespace Fast_io;
struct edge {
  int nxt, to, dis;
} e[N << 1];
struct Edge {
  int u, v, w, id, ans;
} E[M];
bool cmp(Edge x, Edge y) { return x.w < y.w; }
bool cmmp(Edge x, Edge y) { return x.id < y.id; }
int head[N], cnt;
void add(int u, int v, int w) {
  e[++cnt].nxt = head[u];
  e[cnt].to = v;
  e[cnt].dis = w;
  head[u] = cnt;
}
int n, m, fa[N], vis[M];
int find(int k) { return fa[k] == k ? k : fa[k] = find(fa[k]); }
int f[N][logN], Max[N][logN], dep[N];
void dfs(int u, int Fa) {
  for (int i = head[u], v; i; i = e[i].nxt) {
    v = e[i].to;
    if (v == Fa) continue;
    dep[v] = dep[u] + 1;
    f[v][0] = u, Max[v][0] = e[i].dis;
    dfs(v, u);
  }
}
void init() {
  for (int j = 1; j < logN; j++)
    for (int i = 1; i <= n; i++)
      f[i][j] = f[f[i][j - 1]][j - 1],
      Max[i][j] = max(Max[i][j - 1], Max[f[i][j - 1]][j - 1]);
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int k = logN - 1; k >= 0; k--)
    if (dep[f[u][k]] >= dep[v]) u = f[u][k];
  if (u == v) return u;
  for (int k = logN - 1; k >= 0; k--)
    if (f[u][k] != f[v][k]) u = f[u][k], v = f[v][k];
  return f[u][0];
}
int query(int u, int lca) {
  int ans = 0;
  for (int k = logN - 1; k >= 0; k--)
    if (dep[f[u][k]] >= dep[lca]) ans = max(ans, Max[u][k]), u = f[u][k];
  return ans;
}
int main() {
  read(n, m);
  for (int i = 1; i <= m; i++) read(E[i].u, E[i].v), read(E[i].w), E[i].id = i;
  sort(E + 1, E + 1 + m, cmp);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1, sum = 0; i <= m; i++) {
    int uf = find(E[i].u), vf = find(E[i].v);
    if (uf != vf) {
      fa[uf] = vf;
      vis[i] = 1;
      E[i].ans = -1;
      add(E[i].u, E[i].v, E[i].w);
      add(E[i].v, E[i].u, E[i].w);
      sum++;
      if (sum == n - 1) break;
    }
  }
  dfs(1, 0);
  init();
  for (int i = 1; i <= m; i++) {
    if (!vis[i]) {
      int lca = LCA(E[i].u, E[i].v);
      E[i].ans = max(query(E[i].u, lca), query(E[i].v, lca));
    }
  }
  sort(E + 1, E + 1 + m, cmmp);
  for (int i = 1; i <= m; i++)
    if (E[i].ans != -1) write(E[i].ans);
  return 0;
}