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("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &first, T2 second) {
  if (first > second) first = second;
}
template <typename T1, typename T2>
inline void chkmax(T1 &first, T2 second) {
  if (first < second) first = second;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
const int N = 1e5 + 5;
int n, m;
int dsu[N];
vector<pair<int, int>> edge[N];
vector<pair<int, pair<int, int>>> edges, v;
set<pair<int, int>> used;
int get(int i) { return i == dsu[i] ? i : dsu[i] = get(dsu[i]); }
bool merge(int i, int j) {
  i = get(i);
  j = get(j);
  if (i == j) return false;
  dsu[i] = j;
  return true;
}
const int LOG = 18;
int t;
int tin[N], tout[N];
pair<int, int> up[LOG][N];
void dfs(int i, int p = -1) {
  tin[i] = t++;
  for (auto j : edge[i]) {
    if (j.first == p) continue;
    up[0][j.first] = {i, j.second};
    dfs(j.first, i);
  }
  tout[i] = t++;
}
bool is_parent(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }
int lca(int a, int b) {
  int ans = 0;
  for (int t = 0; t < 2; ++t) {
    if (tin[a] > tin[b]) swap(a, b);
    if (!is_parent(b, a)) {
      for (int t = LOG; t--;) {
        int c = up[t][b].first;
        if (!is_parent(c, a)) {
          chkmax(ans, up[t][b].second);
          b = c;
        }
      }
      chkmax(ans, up[0][b].second);
      b = up[0][b].first;
    }
    assert(is_parent(b, a));
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  srand(time(0));
  cin >> n >> m;
  edges.resize(m);
  for (int i = 0; i < m; ++i) {
    cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first;
  }
  v = edges;
  sort(edges.begin(), edges.end());
  bool was = false;
  for (int i = 0; i <= n; ++i) dsu[i] = i;
  for (auto i : edges) {
    if (merge(i.second.first, i.second.second)) {
      used.insert(i.second);
      edge[i.second.first].push_back({i.second.second, i.first});
      edge[i.second.second].push_back({i.second.first, i.first});
    }
  }
  up[0][1] = {1, 0};
  dfs(1);
  for (int t = 0; t + 1 < LOG; ++t) {
    for (int i = 1; i <= n; ++i) {
      up[t + 1][i] = {up[t][up[t][i].first].first,
                      max(up[t][i].second, up[t][up[t][i].first].second)};
    }
  }
  for (auto i : v) {
    if (used.count(i.second)) {
      continue;
    }
    cout << lca(i.second.first, i.second.second) << '\n';
  }
}