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;
using ll = long long;
const ll LOG = 20;
const ll inf = 1e18;
const int N = 2 * 1e5 + 10;
ll res;
ll a[N], p[N];
map<pair<ll, ll>, ll> mp;
vector<pair<ll, ll> > v[N];
vector<pair<ll, pair<ll, ll> > > vp, query;
ll timer;
ll up[N][LOG + 10], mx[N][LOG + 10];
ll in[N], out[N];
void dfs(ll node, ll parent, ll edge) {
  in[node] = ++timer;
  up[node][0] = parent;
  mx[node][0] = edge;
  for (int i = 1; i <= LOG; ++i) {
    up[node][i] = up[up[node][i - 1]][i - 1];
    mx[node][i] = max(mx[node][i - 1], mx[up[node][i - 1]][i - 1]);
  }
  for (auto i : v[node]) {
    if (i.second != parent) dfs(i.second, node, i.first);
  }
  out[node] = ++timer;
}
bool isAncest(ll u, ll v) { return in[u] <= in[v] && out[v] <= out[u]; }
ll LCA(ll u, ll v) {
  if (isAncest(u, v)) return u;
  if (isAncest(v, u)) return v;
  for (int i = LOG; i >= 0; --i) {
    if (!isAncest(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
ll root(ll x) {
  while (x != p[x]) {
    p[x] = p[p[x]];
    x = p[x];
  }
  return x;
}
void join(ll x, ll y) { p[root(x)] = p[root(y)]; }
ll bar(ll u, ll v) {
  ll ans = 0;
  for (int i = LOG; i >= 0; --i) {
    if (isAncest(u, up[v][i])) {
      ans = max(ans, mx[v][i]);
      v = up[v][i];
    }
  }
  return ans;
}
ll foo(ll u, ll v) {
  ll ancest = LCA(u, v);
  return max(bar(ancest, u), bar(ancest, v));
}
void solve() {
  ll n, m, x, y, z;
  cin >> n >> m;
  for (int i = 0; i < N; ++i) p[i] = i;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y >> z;
    vp.push_back({z, {x, y}});
    mp[{x, y}] = i;
  }
  sort(vp.begin(), vp.end());
  for (auto i : vp) {
    if (root(i.second.first) == root(i.second.second)) {
      query.push_back({mp[{i.second.first, i.second.second}],
                       {i.second.first, i.second.second}});
      continue;
    }
    join(i.second.first, i.second.second);
    v[i.second.first].push_back({i.first, i.second.second});
    v[i.second.second].push_back({i.first, i.second.first});
  }
  dfs(1, 1, 0);
  sort(query.begin(), query.end());
  for (auto i : query) {
    cout << foo(i.second.first, i.second.second) << "\n";
  }
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}