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 <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(long long &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 9;
struct Edge {
  int u, v, w;
  int id;
  int flag = 0;
} edge[maxn];
int fa[maxn];
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
bool cmp(Edge a, Edge b) { return a.w < b.w; }
int n, m;
vector<pair<int, int> > mp[maxn];
int dp[maxn], pa[maxn], sz[maxn];
pair<int, int> son[maxn];
int a[maxn];
void dfs1(int u, int fa) {
  sz[u] = 1;
  pa[u] = fa;
  dp[u] = dp[fa] + 1;
  for (pair<int, int> p : mp[u]) {
    int v = p.first;
    if (v == fa) continue;
    dfs1(v, u);
    sz[u] += sz[v];
    if (sz[v] > sz[son[u].first]) son[u].first = v, son[u].second = p.second;
  }
}
int top[maxn], id[maxn], tim = 0;
void dfs2(int u, int fa, int tp, int cst) {
  id[u] = ++tim;
  top[u] = tp;
  a[tim] = cst;
  if (son[u].first) dfs2(son[u].first, u, tp, son[u].second);
  for (pair<int, int> p : mp[u]) {
    int v = p.first;
    if (v == fa || v == son[u].first) continue;
    dfs2(v, u, v, p.second);
  }
}
int sum[maxn << 2];
void build(int le, int ri, int rt) {
  if (le == ri) {
    sum[rt] = a[le];
    return;
  }
  int mid = (le + ri) >> 1;
  build(le, mid, rt << 1);
  build(mid + 1, ri, rt << 1 | 1);
  sum[rt] = max(sum[rt << 1], sum[rt << 1 | 1]);
}
int query(int L, int R, int le, int ri, int rt) {
  if (le >= L && ri <= R) {
    return sum[rt];
  }
  int res = 0;
  int mid = (le + ri) >> 1;
  if (mid >= L) res = max(res, query(L, R, le, mid, rt << 1));
  if (mid < R) res = max(res, query(L, R, mid + 1, ri, rt << 1 | 1));
  return res;
}
int solve(int u, int v) {
  int res = 0;
  while (top[u] != top[v]) {
    if (dp[top[u]] >= dp[top[v]]) {
      res = max(res, query(id[top[u]], id[u], 1, n, 1));
      u = pa[top[u]];
    } else {
      res = max(res, query(id[top[v]], id[v], 1, n, 1));
      v = pa[top[v]];
    }
  }
  if (id[u] != id[v]) {
    if (id[u] < id[v])
      res = max(res, query(id[u] + 1, id[v], 1, n, 1));
    else
      res = max(res, query(id[v] + 1, id[u], 1, n, 1));
  }
  return res;
}
vector<pair<int, int> > ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &edge[i].u, &edge[i].v, &edge[i].w);
    edge[i].id = i;
  }
  sort(edge + 1, edge + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    int u = edge[i].u;
    int v = edge[i].v;
    int fu = find(u);
    int fv = find(v);
    if (fu == fv) continue;
    fa[fu] = fv;
    edge[i].flag = 1;
    mp[u].push_back(pair<int, int>(v, edge[i].w));
    mp[v].push_back(pair<int, int>(u, edge[i].w));
  }
  dfs1(1, 1);
  dfs2(1, 1, 1, 0);
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    if (edge[i].flag) continue;
    int u = edge[i].u;
    int v = edge[i].v;
    ans.push_back(pair<int, int>(edge[i].id, solve(u, v)));
  }
  sort(ans.begin(), ans.end());
  for (pair<int, int> a : ans) printf("%d ", a.second);
  puts("");
  return 0;
}