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 maxn = 101010;
const int inf = 1e9 + 100100;
vector<pair<int, int>> mst[maxn];
vector<pair<pair<int, int>, int>> e;
vector<int> id;
int par[20][maxn];
int ge[20][maxn];
int p[maxn], sz[maxn];
bool intree[maxn * 10];
int tin[maxn], tout[maxn], t = 0;
int find(int v) {
  if (v == p[v]) return v;
  return p[v] = find(p[v]);
}
bool unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return false;
  if (sz[b] > sz[a]) swap(a, b);
  p[b] = a;
  sz[a] += sz[b];
  return true;
}
void build_mst() {
  for (int i = 0; i < maxn; i++) {
    p[i] = i;
    sz[i] = 1;
  }
  sort(id.begin(), id.end(),
       [](int i, int j) { return e[i].second < e[j].second; });
  for (int i : id) {
    int u = e[i].first.first, v = e[i].first.second, w = e[i].second;
    if (unite(u, v)) {
      mst[u].push_back({v, w});
      mst[v].push_back({u, w});
      intree[i] = true;
    }
  }
}
void lca_precalc(int v, int pre = 0, int prew = 0) {
  tin[v] = ++t;
  par[0][v] = pre;
  ge[0][v] = prew;
  for (int i = 1; i < 20; i++) {
    par[i][v] = par[i - 1][par[i - 1][v]];
    ge[i][v] = max(ge[i - 1][v], ge[i - 1][par[i - 1][v]]);
  }
  for (auto x : mst[v]) {
    if (x.first != pre) lca_precalc(x.first, v, x.second);
  }
  tout[v] = ++t;
}
bool up(int a, int b) {
  if (tin[a] <= tin[b] and tout[a] >= tout[b]) return true;
  return false;
}
int lca(int a, int b) {
  if (up(a, b)) return a;
  if (up(b, a)) return b;
  for (int i = 19; i >= 0; i--) {
    if (!up(par[i][a], b)) a = par[i][a];
  }
  return par[0][a];
}
int mx(int a, int l) {
  if (a == l) return 0;
  int ans = 0;
  for (int i = 19; i >= 0; i--) {
    if (!up(par[i][a], l)) {
      ans = max(ans, ge[i][a]);
      a = par[i][a];
    }
  }
  return max(ans, ge[0][a]);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  e.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> e[i].first.first >> e[i].first.second >> e[i].second;
  }
  for (int i = 0; i < m; i++) {
    id.emplace_back(i);
  }
  tin[0] = -inf;
  tout[0] = inf;
  build_mst();
  lca_precalc(1);
  for (int i = 0; i < m; i++) {
    if (!intree[i]) {
      int l = lca(e[i].first.first, e[i].first.second);
      cout << max(mx(e[i].first.first, l), mx(e[i].first.second, l)) << '\n';
    }
  }
  return 0;
}