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 = 100100;
const int MAXM = 1000005;
const int MAXLOGN = 18;
int N, M;
tuple<int, int, int, int> E[MAXM];
int par[MAXN];
vector<pair<int, int> > adj[MAXN];
int jmp[MAXN][MAXLOGN];
int len[MAXN][MAXLOGN];
int dep[MAXN];
bool bad[MAXM];
int ans[MAXM];
void process() {
  for (int j = 1; j < MAXLOGN; j++)
    for (int i = 0; i < N; i++) {
      jmp[i][j] = jmp[jmp[i][j - 1]][j - 1];
      len[i][j] = max(len[i][j - 1], len[jmp[i][j - 1]][j - 1]);
    }
}
int query(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  int best = 0;
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (dep[jmp[b][i]] >= dep[a]) {
      best = max(best, len[b][i]);
      b = jmp[b][i];
    }
  if (a == b) return best;
  for (int i = MAXLOGN - 1; i >= 0; i--)
    if (jmp[a][i] != jmp[b][i]) {
      best = max(best, len[a][i]);
      best = max(best, len[b][i]);
      a = jmp[a][i];
      b = jmp[b][i];
    }
  return max(best, max(len[a][0], len[b][0]));
}
int find_parent(int x) {
  if (par[x] == x) return x;
  return par[x] = find_parent(par[x]);
}
bool merge(int a, int b) {
  a = find_parent(a), b = find_parent(b);
  if (a == b) return false;
  par[a] = b;
  return true;
}
void dfs(int cur, int prv) {
  for (auto e : adj[cur]) {
    int nxt = e.first, w = e.second;
    if (nxt == prv) continue;
    jmp[nxt][0] = cur;
    len[nxt][0] = w;
    dep[nxt] = dep[cur] + 1;
    dfs(nxt, cur);
  }
}
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0, a, b, e; i < M; i++) {
    cin >> a >> b >> e;
    E[i] = tuple<int, int, int, int>(e, a - 1, b - 1, i);
  }
  sort(E, E + M);
  for (int i = 0; i < N; i++) par[i] = i;
  for (int i = 0, w, a, b, idx; i < M; i++) {
    tie(w, a, b, idx) = E[i];
    if (merge(a, b)) {
      adj[a].emplace_back(b, w);
      adj[b].emplace_back(a, w);
    } else
      bad[idx] = true;
  }
  dfs(0, -1);
  process();
  for (int i = 0, w, a, b, idx; i < M; i++) {
    tie(w, a, b, idx) = E[i];
    if (bad[idx]) ans[idx] = query(a, b);
  }
  for (int i = 0; i < M; i++)
    if (bad[i]) cout << ans[i] << "\n";
  return 0;
}