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;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 1e6 + 7;
vector<pair<pair<int, int>, pair<int, int>>> e;
int n, m, root[MAXN], used[MAXN];
pair<pair<int, int>, pair<int, int>> firste;
vector<pair<int, int>> G[MAXN];
int par[MAXN][20], depth[MAXN], cost[MAXN][20];
int findroot(int x) {
  if (x != root[x]) root[x] = findroot(root[x]);
  return root[x];
}
void dfs(int u, int f) {
  depth[u] = depth[f] + 1;
  par[u][0] = f;
  for (int i = 1; par[u][i - 1]; i++) {
    par[u][i] = par[par[u][i - 1]][i - 1];
    cost[u][i] = max(cost[u][i - 1], cost[par[u][i - 1]][i - 1]);
  }
  for (auto E : G[u]) {
    int v = E.first;
    int c = E.second;
    if (v == f) continue;
    cost[v][0] = c;
    dfs(v, u);
  }
}
int ikun(int u, int v) {
  int maxx = 0;
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = 0; depth[u] - depth[v]; i++)
    if ((depth[u] - depth[v]) & (1 << i)) {
      maxx = max(maxx, cost[u][i]);
      u = par[u][i];
    }
  if (u == v) return maxx;
  for (int i = 19; i >= 0; i--)
    if (par[u][i] != par[v][i]) {
      maxx = max(maxx, max(cost[u][i], cost[v][i]));
      u = par[u][i];
      v = par[v][i];
    }
  return max(maxx, max(cost[u][0], cost[v][0]));
}
int main() {
  ____();
  cin >> n >> m;
  e.resize(m);
  for (int i = 0; i < m; i++)
    cin >> e[i].first.first >> e[i].first.second >> e[i].second.first;
  for (int i = 0; i < m; i++) e[i].second.second = i;
  sort(e.begin(), e.end(),
       [](const pair<pair<int, int>, pair<int, int>> &A,
          const pair<pair<int, int>, pair<int, int>> &B) {
         return A.second.first < B.second.first;
       });
  for (int i = 1; i <= n; i++) root[i] = i;
  for (int i = 0; i < m; i++) {
    int u = e[i].first.first;
    int v = e[i].first.second;
    if (findroot(u) == findroot(v)) continue;
    root[findroot(u)] = findroot(v);
    used[e[i].second.second] = 1;
  }
  for (int i = 0; i < m; i++) {
    if (!used[e[i].second.second]) continue;
    auto p = e[i];
    G[p.first.first].emplace_back(make_pair(p.first.second, p.second.first));
    G[p.first.second].emplace_back(make_pair(p.first.first, p.second.first));
  }
  dfs(1, 0);
  sort(e.begin(), e.end(),
       [](const pair<pair<int, int>, pair<int, int>> &A,
          const pair<pair<int, int>, pair<int, int>> &B) {
         return A.second.second < B.second.second;
       });
  for (int i = 0; i < m; i++)
    if (!used[i]) cout << ikun(e[i].first.first, e[i].first.second) << endl;
  return 0;
}