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 = 1e5 + 5, M = 1e6 + 6, LG = 20;
int a[M], b[M], e[M];
int id[M];
int p[N];
int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
bool merge(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return false;
  if (-p[u] < -p[v]) swap(u, v);
  p[u] += p[v];
  p[v] = u;
  return true;
}
int par[LG][N], w[LG][N];
vector<pair<int, int> > g[N];
int lv[N];
int ans[M];
void dfs(int v, int pp = -1) {
  lv[v] = pp == -1 ? 0 : lv[pp] + 1;
  par[0][v] = pp == -1 ? v : pp;
  for (int i = 0; i + 1 < LG; ++i) {
    par[i + 1][v] = par[i][par[i][v]];
    w[i + 1][v] = max(w[i][v], w[i][par[i][v]]);
  }
  for (auto it : g[v]) {
    if (it.first == pp) continue;
    w[0][it.first] = it.second;
    dfs(it.first, v);
  }
}
int get_max(int u, int v) {
  if (lv[u] > lv[v]) swap(u, v);
  int diff = lv[v] - lv[u];
  int ret = 0;
  for (int i = 0; i < LG; ++i) {
    if (diff & (1 << i)) {
      ret = max(ret, w[i][v]);
      v = par[i][v];
    }
  }
  if (u == v) return ret;
  for (int i = LG - 1; i >= 0; --i) {
    if (par[i][u] != par[i][v]) {
      ret = max(ret, max(w[i][u], w[i][v]));
      u = par[i][u];
      v = par[i][v];
    }
  }
  return max(ret, max(w[0][u], w[0][v]));
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", a + i, b + i, e + i);
  }
  iota(id, id + m, 0);
  sort(id, id + m, [](int l, int r) { return e[l] < e[r]; });
  memset(p, -1, sizeof p);
  for (int i = 0; i < m; ++i) {
    int cur = id[i];
    if (merge(a[cur], b[cur])) {
      ans[cur] = -1;
      g[a[cur]].emplace_back(b[cur], e[cur]);
      g[b[cur]].emplace_back(a[cur], e[cur]);
    }
  }
  dfs(1);
  for (int i = 0; i < m; ++i) {
    if (ans[i] == -1) continue;
    ans[i] = get_max(a[i], b[i]);
    printf("%d\n", ans[i]);
  }
  return 0;
}