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;
const long long N = 100111;
const long long inf = 1e10;
long long n, m;
vector<pair<pair<long long, long long>, long long> > g[N];
vector<pair<pair<long long, long long>, long long> > a;
bool use[10 * N];
long long ans[N];
long long d[N];
bool used[N];
long long tt[N];
long long get_id[N];
long long t[4 * N];
void build(long long v, long long l, long long r) {
  if (l == r) {
    t[v] = ans[l];
  } else {
    long long mid = (l + r) / 2;
    build(v + v, l, mid);
    build(v + v + 1, mid + 1, r);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
  }
}
long long get(long long v, long long tl, long long tr, long long l,
              long long r) {
  if (l > r) return 0;
  if (l == tl && r == tr) return t[v];
  long long tm = (tl + tr) / 2;
  return max(get(v * 2, tl, tm, l, min(r, tm)),
             get(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y, z;
    cin >> x >> y >> z;
    g[x].push_back({{y, z}, i - 1});
    g[y].push_back({{x, z}, i - 1});
    a.push_back({{x, y}, z});
  }
  for (long long i = 1; i <= n; i++) {
    d[i] = inf;
  }
  d[1] = 0;
  set<pair<pair<long long, long long>, long long> > q;
  q.insert({{0, 1}, m + 1});
  long long cnt = 0;
  while (!q.empty()) {
    cnt++;
    long long v = q.begin()->first.second;
    used[v] = 1;
    tt[v] = cnt;
    long long may = q.begin()->first.first;
    ans[cnt] = may;
    use[q.begin()->second] = 1;
    d[v] = 0;
    q.erase(q.begin());
    for (long long i = 0; i < g[v].size(); i++) {
      long long to = g[v][i].first.first;
      long long cost = g[v][i].first.second;
      long long id = g[v][i].second;
      if (cost < d[to] && !used[to]) {
        if (d[to] != inf) {
          q.erase({{d[to], to}, get_id[to]});
        }
        d[to] = cost;
        get_id[to] = id;
        q.insert({{d[to], to}, get_id[to]});
      }
    }
  }
  build(1, 1, n);
  for (long long i = 0; i < a.size(); i++) {
    if (use[i] == 0) {
      long long x = a[i].first.first;
      long long y = a[i].first.second;
      if (tt[x] > tt[y]) {
        swap(x, y);
      }
      cout << get(1, 1, n, tt[x] + 1, tt[y]) << "\n";
    }
  }
  return 0;
}