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>
#pragma GCC optimize("O3")
using namespace std;
int const N = 1e5 + 9, M = 1e6 + 9;
int p[N];
int rnk[N];
int parent(int x) {
  if (p[x] == x) return x;
  return p[x] = parent(p[x]);
}
bool isConnected(int x, int y) { return parent(x) == parent(y); }
void connect(int x, int y) {
  if (isConnected(x, y)) return;
  int pOfx = parent(x);
  int pOfy = parent(y);
  if (rnk[pOfx] > rnk[pOfy]) {
    p[pOfy] = pOfx;
  } else if (rnk[pOfy] > rnk[pOfx]) {
    p[pOfx] = pOfy;
  } else {
    p[pOfy] = pOfx;
    rnk[pOfx]++;
  }
}
void preDSU() {
  for (int i = 0; i < N; i++) {
    p[i] = i;
    rnk[i] = 0;
  }
}
int x[M], y[M], val[M];
set<int> st;
vector<pair<int, int>> adj[N];
int n, m;
int par[N][18], mx[N][18], depth[N];
void dfs(int v, int p, int c = 0) {
  par[v][0] = p;
  mx[v][0] = c;
  depth[v] = 1 + depth[p];
  for (auto i : adj[v])
    if (i.first != p) dfs(i.first, v, i.second);
}
void build() {
  for (int j = 1; j < 18; j++)
    for (int i = 1; i <= n; i++) {
      par[i][j] = par[par[i][j - 1]][j - 1];
      mx[i][j] = max(mx[i][j - 1], mx[par[i][j - 1]][j - 1]);
    }
}
int query(int u, int v) {
  if (depth[v] > depth[u]) swap(u, v);
  int diff = depth[u] - depth[v];
  int ret = 0;
  for (int i = 17; i >= 0; i--) {
    if (diff & (1 << i)) {
      ret = max(ret, mx[u][i]);
      u = par[u][i];
    }
  }
  if (u == v) return ret;
  for (int i = 17; i >= 0; i--) {
    if (par[u][i] != par[v][i]) {
      int uu = u, vv = v;
      u = par[u][i], v = par[v][i];
      ret = max(ret, mx[vv][i]);
      ret = max(ret, mx[uu][i]);
    }
  }
  ret = max(ret, mx[u][0]);
  ret = max(ret, mx[v][0]);
  return ret;
}
vector<pair<int, int>> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    st.insert(i);
    cin >> x[i] >> y[i] >> val[i];
    v.push_back({val[i], i});
  }
  sort(v.begin(), v.end());
  preDSU();
  for (auto i : v) {
    if (!isConnected(x[i.second], y[i.second])) {
      connect(x[i.second], y[i.second]);
      st.erase(i.second);
      adj[y[i.second]].push_back({x[i.second], val[i.second]});
      adj[x[i.second]].push_back({y[i.second], val[i.second]});
    }
  }
  dfs(1, 0);
  build();
  for (auto i : st) {
    int u = x[i];
    int v = y[i];
    int ans = query(u, v);
    cout << ans << '\n';
  }
  return 0;
}