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;
struct Edge {
  int a, b, e, i;
};
class UnionFind {
 private:
  vector<int> p, r;

 public:
  UnionFind(int n) {
    r.assign(n, 0);
    p.assign(n, 0);
    iota(begin(p), end(p), 0);
  }
  int findset(int i) { return (p[i] == i) ? i : (p[i] = findset(p[i])); }
  bool unionset(int i, int j) {
    int x = findset(i), y = findset(j);
    if (x != y) {
      if (r[x] > r[y])
        p[y] = x;
      else {
        p[x] = y;
        if (r[x] == r[y]) ++r[y];
      }
      return true;
    } else
      return false;
  }
};
const int N = 1e5 + 10;
const int lgN = 18;
const int M = 1e6 + 10;
int n, m;
vector<Edge> el;
vector<pair<int, int> > al[N];
bool used[M];
int d[N];
pair<int, int> pa[N][lgN];
void dfs(int u) {
  for (int k = 1; k <= lgN - 1; ++k)
    pa[u][k] = pair<int, int>(
        pa[pa[u][k - 1].first][k - 1].first,
        max(pa[u][k - 1].second, pa[pa[u][k - 1].first][k - 1].second));
  for (auto v : al[u])
    if (v.first != pa[u][0].first)
      d[v.first] = d[u] + 1, pa[v.first][0] = pair<int, int>(u, v.second),
      dfs(v.first);
}
int ans(int a, int b) {
  if (d[a] < d[b]) swap(a, b);
  int maxi = 0;
  for (int k = lgN - 1; k >= 0; --k)
    if (pa[a][k].first != 0 and d[pa[a][k].first] >= d[b])
      maxi = max(maxi, pa[a][k].second), a = pa[a][k].first;
  if (a == b) return maxi;
  for (int k = lgN - 1; k >= 0; --k)
    if (pa[a][k].first != 0 and pa[b][k].first != 0 and
        pa[a][k].first != pa[b][k].first)
      maxi = max(maxi, max(pa[a][k].second, pa[b][k].second)),
      a = pa[a][k].first, b = pa[b][k].first;
  maxi = max(maxi, max(pa[a][0].second, pa[b][0].second));
  return maxi;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i <= m - 1; ++i) {
    int a, b, e;
    cin >> a >> b >> e;
    el.push_back({a, b, e, i});
  }
  sort(begin(el), end(el), [](Edge a, Edge b) {
    if (a.e == b.e)
      return a.i < b.i;
    else
      return a.e < b.e;
  });
  UnionFind UF(n + 1);
  for (auto& e : el) {
    if (UF.unionset(e.a, e.b))
      used[e.i] = 1, al[e.a].emplace_back(e.b, e.e),
      al[e.b].emplace_back(e.a, e.e);
  }
  d[1] = 0;
  dfs(1);
  sort(begin(el), end(el), [](Edge a, Edge b) { return a.i < b.i; });
  for (int i = 0; i <= m - 1; ++i)
    if (!used[i]) cout << ans(el[i].a, el[i].b) << '\n';
}