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,avx,tune=native")
using namespace std;
const int inf_int = 1e9 + 100;
const long long inf_ll = 1e18;
const double pi = 3.1415926535898;
bool debug = 0;
const int MAXN = 1e6 + 100;
const int LOG = 25;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
const long long MOD = 1000000000949747713ll;
int A[MX], B[MX], C[MX];
int parent[MAXN];
void build(int n) {
  for (int i = 1; i <= n; ++i) {
    parent[i] = i;
  }
}
int find_parent(int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_parent(parent[v]);
}
mt19937 mt(228);
bool union_set(int a, int b) {
  a = find_parent(a);
  b = find_parent(b);
  if (a != b) {
    if (mt() & 1) swap(a, b);
    parent[b] = a;
    return true;
  }
  return false;
}
vector<pair<int, int> > g[MAXN];
int up[MAXN][LOG];
int val[MAXN][LOG];
int h[MAXN];
void dfs(int v, int p, int dis) {
  up[v][0] = p;
  val[v][0] = dis;
  for (int i = 1; i < LOG; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (int i = 1; i < LOG; ++i) {
    val[v][i] = max(val[up[v][i - 1]][i - 1], val[v][i - 1]);
  }
  for (pair<int, int> x : g[v]) {
    int to = x.first;
    if (to == p) continue;
    h[to] = h[v] + 1;
    dfs(to, v, x.second);
  }
}
int lca(int a, int b) {
  if (h[b] < h[a]) swap(a, b);
  int dif = h[b] - h[a];
  for (int i = 0; i < LOG; ++i) {
    if (dif & (1 << i)) b = up[b][i];
  }
  assert(h[a] == h[b]);
  if (a == b) return a;
  for (int i = LOG - 1; i >= 0; --i) {
    if (up[a][i] != up[b][i]) {
      a = up[a][i];
      b = up[b][i];
    }
  }
  return up[a][0];
}
int get_mx(int a, int lc) {
  assert(h[lc] <= h[a]);
  int res = 0;
  if (a == lc) return res;
  for (int i = LOG - 1; i >= 0; --i) {
    if (h[up[a][i]] > h[lc]) {
      res = max(res, val[a][i]);
      a = up[a][i];
    }
  }
  res = max(res, val[a][0]);
  return res;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > cc;
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    cc.push_back({c, i});
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }
  sort(cc.begin(), cc.end());
  vector<int> rest;
  build(n);
  for (auto x : cc) {
    int id = x.second;
    if (union_set(A[id], B[id])) {
      g[A[id]].push_back({B[id], C[id]});
      g[B[id]].push_back({A[id], C[id]});
    } else {
      rest.push_back(id);
    }
  }
  sort(rest.begin(), rest.end());
  dfs(1, 1, 0);
  for (int v : rest) {
    int lc = lca(A[v], B[v]);
    if (debug) cout << A[v] << " " << B[v] << " : " << lc << endl;
    int res = max(get_mx(A[v], lc), get_mx(B[v], lc));
    cout << res << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  int t = 1;
  while (t--) solve();
  if (debug)
    cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}