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;
struct edge2 {
  int u, v, w, i;
};
struct edge {
  int v, w;
};
vector<edge> g[100001];
int fs[100001];
int ff(int x) { return fs[x] ? fs[x] = ff(fs[x]) : x; }
bool fu(int x, int y) {
  x = ff(x);
  y = ff(y);
  if (x != y) fs[x] = y;
  return x != y;
}
int mp[100001][18], ms[100001][18], dep[100001];
void dfs(int u, int f, int w) {
  mp[u][0] = f;
  ms[u][0] = w;
  dep[u] = dep[f] + 1;
  for (edge e : g[u]) {
    if (e.v == f) continue;
    dfs(e.v, u, e.w);
  }
}
void lca_init(int n) {
  for (int j = 1; (1 << j) < n; ++j)
    for (int i = 1; i <= n; ++i)
      mp[i][j] = mp[mp[i][j - 1]][j - 1],
      ms[i][j] = max(ms[i][j - 1], ms[mp[i][j - 1]][j - 1]);
}
int lca(int u, int v) {
  int res = 0;
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 17; dep[u] - dep[v]; --i)
    if ((1 << i) & (dep[u] - dep[v])) res = max(res, ms[u][i]), u = mp[u][i];
  if (u == v) return res;
  for (int i = 17; i >= 0; --i)
    if (mp[u][i] != mp[v][i])
      res = max({res, ms[u][i], ms[v][i]}), u = mp[u][i], v = mp[v][i];
  return max({res, ms[u][0], ms[v][0]});
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<edge2> es, es2;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    es.push_back({u, v, w, i});
  }
  sort(es.begin(), es.end(), [](edge2 e1, edge2 e2) { return e1.w < e2.w; });
  for (edge2 e : es) {
    if (!fu(e.u, e.v))
      es2.push_back(e);
    else {
      g[e.u].push_back({e.v, e.w});
      g[e.v].push_back({e.u, e.w});
    }
  }
  dfs(1, 0, 0);
  lca_init(n);
  sort(es2.begin(), es2.end(), [](edge2 e1, edge2 e2) { return e1.i < e2.i; });
  for (edge2 e : es2) {
    cout << lca(e.u, e.v) << endl;
  }
  return 0;
}