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;
template <typename T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
const long long M = 1e6 + 10;
const long long N = 1e5 + 10;
long long n, m, cnt, head[N], ta, tb, fa[N], f[N][30], dep[N], dis[N][30];
bool vis[M];
struct node {
  long long to, from, dis, id;
} E[M << 1];
struct EE {
  long long to, next, dis;
} edge[N << 1];
inline bool cmp(node x, node y) { return x.dis < y.dis; }
inline bool cmp1(node x, node y) { return x.id < y.id; }
inline long long find(long long k) {
  return fa[k] == k ? k : fa[k] = find(fa[k]);
}
inline void add(long long u, long long v, long long w) {
  edge[++cnt] = {v, head[u], w};
  head[u] = cnt;
}
inline void build(long long u, long long fa) {
  dep[u] = dep[fa] + 1, f[u][0] = fa;
  for (long long i = 0; f[u][i]; i++)
    f[u][i + 1] = f[f[u][i]][i],
             dis[u][i + 1] = max(dis[u][i], dis[f[u][i]][i]);
  for (long long i = head[u]; i; i = edge[i].next) {
    long long v = edge[i].to;
    if (v == fa) continue;
    dis[v][0] = edge[i].dis;
    build(v, u);
  }
}
inline long long LCA(long long u, long long v) {
  long long d = 0;
  if (dep[u] > dep[v]) swap(u, v);
  for (long long i = 20; ~i; i--)
    if (dep[v] - (1 << i) >= dep[u]) chmax(d, dis[v][i]), v = f[v][i];
  if (v == u) return d;
  for (long long i = 20; ~i; i--)
    if (f[v][i] != f[u][i])
      d = max(d, max(dis[v][i], dis[u][i])), v = f[v][i], u = f[u][i];
  return max(d, max(dis[u][0], dis[v][0]));
}
signed main() {
  n = read(), m = read();
  long long u, v, w;
  for (long long i = 1; i <= m; i++)
    E[i].from = read(), E[i].to = read(), E[i].dis = read(), E[i].id = i;
  for (long long i = 1; i <= n; i++) fa[i] = i;
  sort(E + 1, E + 1 + m, cmp);
  long long tmp = 0;
  for (long long i = 1; i <= m && tmp < n - 1; i++) {
    u = find(E[i].from), v = find(E[i].to);
    if (u == v) continue;
    fa[u] = v;
    tmp++;
    vis[E[i].id] = 1;
    add(E[i].from, E[i].to, E[i].dis);
    add(E[i].to, E[i].from, E[i].dis);
  }
  build(1, 0);
  sort(E + 1, E + 1 + m, cmp1);
  for (long long i = 1; i <= m; i++)
    if (!vis[i]) cout << LCA(E[i].from, E[i].to) << endl;
  return 0;
  ;
}