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;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
int n, m;
const int MaxN = 1e5 + 100;
const int LgMaxN = 18;
int fu_parent[MaxN];
vector<pii> tree_adj[MaxN];
int parent[LgMaxN][MaxN];
int max_edge[LgMaxN][MaxN];
int depth[MaxN];
int FuFind(int v) {
  if (v == fu_parent[v]) {
    return v;
  }
  return fu_parent[v] = FuFind(fu_parent[v]);
}
bool FuUnion(int a, int b) {
  a = FuFind(a);
  b = FuFind(b);
  if (a != b) {
    fu_parent[a] = b;
    return true;
  }
  return false;
}
void DfsTree(int v, int p) {
  parent[0][v] = p;
  for (int i = 1; i < LgMaxN; ++i) {
    const int g = parent[i - 1][v];
    parent[i][v] = parent[i - 1][g];
    max_edge[i][v] = max(max_edge[i - 1][v], max_edge[i - 1][g]);
  }
  for (auto &&[s, c] : tree_adj[v]) {
    if (s == p) {
      continue;
    }
    max_edge[0][s] = c;
    depth[s] = depth[v] + 1;
    DfsTree(s, v);
  }
}
int LCA(int a, int b) {
  if (depth[a] > depth[b]) {
    swap(a, b);
  }
  const int d = depth[b] - depth[a];
  for (int i = 0; i < LgMaxN; ++i) {
    if (d & (1 << i)) {
      b = parent[i][b];
    }
  }
  if (a == b) {
    return a;
  }
  for (int i = LgMaxN - 1; i >= 0; --i) {
    const int pa = parent[i][a];
    const int pb = parent[i][b];
    if (pa != pb) {
      a = pa;
      b = pb;
    }
  }
  return parent[0][a];
}
int MaxPathUp(int a, int v) {
  const int d = depth[a] - depth[v];
  int ans = 0;
  for (int i = 0; i < LgMaxN; ++i) {
    if ((d >> i) & 1) {
      ans = max(ans, max_edge[i][a]);
      a = parent[i][a];
    }
  }
  return ans;
}
int GetAns(int a, int b) {
  const int L = LCA(a, b);
  return max(MaxPathUp(a, L), MaxPathUp(b, L));
}
int main() {
  scanf("%d%d", &n, &m);
  map<int, int> cost_map;
  vector<tuple<int, int, int>> edges(m);
  for (int i = 0; i < m; ++i) {
    auto &[c, a, b] = edges[i];
    scanf("%d%d%d", &a, &b, &c);
    cost_map[c] = i;
  }
  sort(edges.begin(), edges.end());
  iota(fu_parent, fu_parent + n + 1, 0);
  vi answers(m, -1);
  vector<bool> need_ans(m);
  for (int i = 0; i < m; ++i) {
    auto &&[c, a, b] = edges[i];
    if (FuUnion(a, b)) {
      tree_adj[a].emplace_back(b, c);
      tree_adj[b].emplace_back(a, c);
    } else {
      need_ans[i] = true;
    }
  }
  DfsTree(1, 1);
  for (int i = 0; i < m; ++i) {
    if (need_ans[i]) {
      auto &&[c, a, b] = edges[i];
      debug() << " ["
              << "c"
                 ": "
              << (c) << "] "
              << " ["
              << "a"
                 ": "
              << (a) << "] "
              << " ["
              << "b"
                 ": "
              << (b) << "] ";
      answers[cost_map[c]] = GetAns(a, b);
    }
  }
  for (int i = 0; i < m; ++i) {
    if (answers[i] != -1) {
      printf("%d\n", answers[i]);
    }
  }
}