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 = 1000000 + 77, L = 20;
int n, m, Ev[N], Eu[N], Ew[N], d[N], Par[N][L], Mx[N][L], PD[N], Pr[N];
bool M[N];
vector<int> adj[N];
int Find(int x) { return PD[x] <= 0 ? x : (PD[x] = Find(PD[x])); }
inline bool Merge(int v, int u) {
  int nv = Find(v);
  int nu = Find(u);
  if (nv == nu) return 0;
  PD[nv] = nu;
  return 1;
}
void dfs(int v, int prev = -1) {
  for (int i = 1; i < L; ++i)
    Par[v][i] = Par[Par[v][i - 1]][i - 1],
    Mx[v][i] = max(Mx[v][i - 1], Mx[Par[v][i - 1]][i - 1]);
  for (int id : adj[v]) {
    int u = Ev[id] ^ Eu[id] ^ v;
    if (u == prev) continue;
    Par[u][0] = v;
    Mx[u][0] = Ew[id];
    d[u] = d[v] + 1;
    dfs(u, v);
  }
}
inline int GetPar(int v, int k) {
  for (int i = 0; i < L; ++i)
    if ((1 << i) & k) v = Par[v][i];
  return v;
}
inline int GetLca(int v, int u) {
  if (d[v] < d[u]) swap(v, u);
  v = GetPar(v, d[v] - d[u]);
  if (v == u) return v;
  for (int i = L - 1; i >= 0; --i)
    if (Par[v][i] != Par[u][i]) v = Par[v][i], u = Par[u][i];
  return Par[v][0];
}
inline int GetMax(int v, int k) {
  int r = 0;
  for (int i = 0; i < L; ++i)
    if ((1 << i) & k) r = max(r, Mx[v][i]), v = Par[v][i];
  return r;
}
inline int GetPath(int v, int u) {
  int Lca = GetLca(v, u);
  return max(GetMax(v, d[v] - d[Lca]), GetMax(u, d[u] - d[Lca]));
}
bool CMP(int x, int y) { return Ew[x] < Ew[y]; }
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i)
    scanf("%d %d %d", Ev + i, Eu + i, Ew + i), Pr[i] = i;
  sort(Pr + 1, Pr + m + 1, CMP);
  for (int i = 1; i <= m; ++i) {
    int id = Pr[i];
    M[id] = Merge(Ev[id], Eu[id]);
    if (M[id]) adj[Ev[id]].push_back(id), adj[Eu[id]].push_back(id);
  }
  dfs(1);
  for (int i = 1; i <= m; ++i) {
    if (!M[i]) {
      printf("%d\n", GetPath(Ev[i], Eu[i]));
    }
  }
  return 0;
}