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;
long long p[300200];
long long lg = 19;
long long dp[300200][20];
long long mx[300200][20];
vector<pair<long long, long long> > g[300200];
map<pair<long long, long long>, long long> mp;
pair<long long, long long> par[300200];
long long h[300200];
map<long long, pair<long long, long long> > rmp;
void make_set(long long v) { p[v] = v; }
long long get(long long v) {
  if (v == p[v]) return v;
  return p[v] = get(p[v]);
}
void unite(long long a, long long b) {
  a = get(a);
  b = get(b);
  if (rand() & 1)
    p[a] = b;
  else
    p[b] = a;
}
void add(long long a, long long b, long long cost) {
  dp[b][0] = a;
  mx[b][0] = cost;
  for (long long i = 1; i <= lg; ++i) {
    dp[b][i] = dp[dp[b][i - 1]][i - 1];
    mx[b][i] = max(mx[dp[b][i - 1]][i - 1], mx[b][i - 1]);
  }
}
void dfs(long long v, long long pr = -1) {
  for (long long i = 0; i < g[v].size(); ++i) {
    long long to = g[v][i].first;
    long long cost = g[v][i].second;
    if (to == pr) continue;
    add(v, to, cost);
    h[to] = h[v] + 1;
    dfs(to, v);
  }
}
bool used[1300200];
long long lca(long long v, long long u) {
  long long ma = -2e9;
  if (h[v] > h[u]) swap(v, u);
  for (long long i = lg; i >= 0; --i) {
    if (h[u] - h[v] >= (1 << i)) {
      ma = max(ma, mx[u][i]);
      u = dp[u][i];
    }
  }
  if (u == v) {
    if (ma != -2e9)
      return ma;
    else
      return 0;
  }
  for (long long i = lg - 1; i >= 0; --i) {
    if (dp[v][i] != dp[u][i]) {
      ma = max(mx[u][i], ma);
      ma = max(mx[v][i], ma);
      v = dp[v][i];
      u = dp[u][i];
    }
  }
  if (u != v) ma = max({ma, mx[u][0], mx[v][0]});
  if (ma != -2e9)
    return ma;
  else
    return 0;
}
signed main() {
  srand(time(0));
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, pair<long long, long long> > > edges;
  for (long long i = 0; i < n; ++i) make_set(i);
  for (long long i = 0; i < m; ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    if (a > b) swap(a, b);
    edges.push_back({c, {a, b}});
    mp[{a, b}] = i;
    rmp[i] = {a, b};
  }
  sort(edges.begin(), edges.end());
  for (long long i = 0; i < edges.size(); ++i) {
    long long c = edges[i].first;
    long long a = edges[i].second.first;
    long long b = edges[i].second.second;
    if (get(a) != get(b)) {
      unite(a, b);
      g[a].push_back({b, c});
      g[b].push_back({a, c});
      used[mp[{a, b}]] = 1;
    }
  }
  dfs(0);
  vector<pair<long long, long long> > ans;
  for (long long i = 0; i < m; ++i) {
    if (used[i]) {
      continue;
    }
    long long a = rmp[i].first;
    long long b = rmp[i].second;
    long long mm = lca(a, b);
    cout << mm << " ";
  }
  return 0;
}