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;
using P = pair<int, int>;
using PP = pair<P, P>;
using VPP = vector<PP>;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<int>;
using VVI = vector<VI>;
VI pare;
VVP G;
VI prof;
VVI J, mx;
int repre(int x) { return (pare[x] == -1 ? x : pare[x] = repre(pare[x])); }
void dfs(int x, int p, int pr) {
  prof[x] = pr;
  J[x][0] = p;
  for (int b = 1; b < 20; ++b) J[x][b] = J[J[x][b - 1]][b - 1];
  for (int b = 1; b < 20; ++b)
    mx[x][b] = max(mx[x][b - 1], mx[J[x][b - 1]][b - 1]);
  for (P e : G[x]) {
    int y = e.first;
    if (y != p) {
      mx[y][0] = e.second;
      dfs(y, x, pr + 1);
    }
  }
}
int up(int x, int masc) {
  for (int b = 0; b < 20; ++b)
    if ((masc >> b) & 1) x = J[x][b];
  return x;
}
int lca(int x, int y) {
  if (prof[x] > prof[y]) return lca(y, x);
  y = up(y, prof[y] - prof[x]);
  for (int b = 19; b >= 0; --b) {
    int jx = J[x][b];
    int jy = J[y][b];
    if (jx != jy) {
      x = jx;
      y = jy;
    }
  }
  return (x == y ? x : J[x][0]);
}
int maxim(int x, int masc) {
  int res = 0;
  for (int b = 0; b < 20; ++b)
    if ((masc >> b) & 1) {
      res = max(res, mx[x][b]);
      x = J[x][b];
    }
  return res;
}
int solu(int x, int y) {
  int pr = prof[lca(x, y)];
  return max(maxim(x, prof[x] - pr), maxim(y, prof[y] - pr));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  VPP E(m);
  for (int i = 0; i < m; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    E[i] = PP(P(c, i), P(x - 1, y - 1));
  }
  sort(E.begin(), E.end());
  G = VVP(n);
  pare = VI(n, -1);
  for (PP& e : E) {
    int x = e.second.first;
    int y = e.second.second;
    int rx = repre(x);
    int ry = repre(y);
    if (rx != ry) {
      pare[ry] = rx;
      int c = e.first.first;
      G[x].push_back(P(y, c));
      G[y].push_back(P(x, c));
      e.first.second = -1;
    }
  }
  prof = VI(n);
  J = mx = VVI(n, VI(20));
  dfs(0, 0, 0);
  VI res(m, -1);
  for (PP e : E) {
    int i = e.first.second;
    if (i != -1) res[i] = solu(e.second.first, e.second.second);
  }
  for (int r : res)
    if (r != -1) cout << r << '\n';
}