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 inf = (long long)2e9;
const long long md = 1000000007;
long long dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
long long power(long long a, long long p, long long md) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans *= a;
    p /= 2;
    a *= a;
    ans %= md;
    a %= md;
  }
  return ans;
}
long long mdinv(long long a) { return power(a, md - 2, md); }
const long long nn = 100005;
class DSU {
 public:
  vector<long long> p, rank, len;
  DSU(long long n) {
    p.assign(n, 0);
    rank = p;
    len = p;
    for (long long i = 0; i < (long long)n; i++) p[i] = i, len[i] = 1;
  }
  long long findSet(long long i) {
    return (p[i] == i) ? i : p[i] = findSet(p[i]);
  }
  long long setSize(long long i) {
    i = findSet(i);
    return len[i];
  }
  bool merge(long long first, long long second) {
    first = findSet(first);
    second = findSet(second);
    if (first == second) return 0;
    if (rank[first] < rank[second]) swap(first, second);
    p[second] = first;
    len[first] += len[second];
    if (rank[first] == rank[second]) rank[first]++;
    return 1;
  }
};
vector<long long> adj[nn], adw[nn];
long long vis[nn];
set<pair<long long, long long>> bMST;
long long sqrtN;
long long prevs[nn], sto[nn];
long long lvl[nn], pr[nn], prW[nn];
void dfs(long long u, long long level, long long parent, long long wt) {
  vis[u] = 1;
  pr[u] = parent;
  prW[u] = wt;
  lvl[u] = level;
  if (level % sqrtN) {
    prevs[u] = prevs[parent];
    sto[u] = max(wt, sto[parent]);
  } else {
    prevs[u] = parent;
    sto[u] = wt;
  }
  for (long long i = 0; i < (long long)(long long)(adj[u].size()); i++) {
    long long v = adj[u][i], w = adw[u][i];
    if (!vis[v]) {
      dfs(v, level + 1, u, w);
    }
  }
}
long long cusDis(long long a, long long b) {
  long long ansA = 0, ansB = 0;
  while (prevs[a] != prevs[b]) {
    if (lvl[a] > lvl[b]) {
      ansA = max(ansA, sto[a]);
      a = prevs[a];
    } else {
      ansB = max(ansB, sto[b]);
      b = prevs[b];
    }
  }
  while (a != b) {
    if (lvl[a] > lvl[b]) {
      ansA = max(ansA, prW[a]);
      a = pr[a];
    } else {
      ansB = max(ansB, prW[b]);
      b = pr[b];
    }
  }
  return max(ansA, ansB);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long a, b, w;
  vector<tuple<long long, long long, long long>> edj, edjAct;
  for (long long i = 0; i < (long long)m; i++) {
    cin >> a >> b >> w;
    a--, b--;
    edj.push_back(make_tuple(w, a, b));
  }
  edjAct = edj;
  sort((edj).begin(), (edj).end());
  DSU dsu(n);
  for (long long i = 0; i < (long long)m; i++) {
    w = get<0>(edj[i]);
    a = get<1>(edj[i]);
    b = get<2>(edj[i]);
    if (dsu.merge(a, b)) {
      adj[a].push_back(b);
      adw[a].push_back(w);
      adj[b].push_back(a);
      adw[b].push_back(w);
      bMST.insert({min(a, b), max(a, b)});
    }
  }
  sqrtN = sqrt(n);
  dfs(0, 0, -1, 0);
  for (long long i = 0; i < (long long)(long long)(edjAct.size()); i++) {
    a = get<1>(edjAct[i]);
    b = get<2>(edjAct[i]);
    if (a > b) swap(a, b);
    if (bMST.count({a, b})) continue;
    cout << cusDis(a, b) << " ";
  }
}