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("O3")
using namespace std;
const long long MOD = 1000000007, LOG = 19;
vector<pair<pair<long long, long long>, pair<long long, long long> > > edges;
long long p[100005], up[100005][LOG], maxi[100005][LOG], in[100005],
    out[100005], idx, ans[1000001];
vector<vector<pair<long long, long long> > > vec;
vector<long long> nt;
long long findSet(long long i) {
  if (p[i] == i) return i;
  return p[i] = findSet(p[i]);
}
bool is_ances(long long a, long long b) {
  return ((in[a] <= in[b]) && (out[a] >= out[b]));
}
void dfs(long long node, long long par, long long w) {
  in[node] = idx++;
  up[node][0] = par, maxi[node][0] = w;
  for (long long i = 1; i < LOG; ++i) up[node][i] = up[up[node][i - 1]][i - 1];
  for (long long i = 1; i < LOG; ++i)
    maxi[node][i] = max(maxi[node][i - 1], maxi[up[node][i - 1]][i - 1]);
  for (auto it : vec[node])
    if (it.second != par) dfs(it.second, node, it.first);
  out[node] = idx++;
}
long long lca(long long a, long long b) {
  if (is_ances(a, b)) return a;
  if (is_ances(b, a)) return b;
  for (long long i = LOG - 1; i >= 0; i--)
    if (!is_ances(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
long long get_max(long long a, long long b) {
  if (a == b) return 0;
  long long ans = 0;
  for (long long i = LOG - 1; i >= 0; i--)
    if (!is_ances(up[a][i], b)) ans = max(ans, maxi[a][i]), a = up[a][i];
  return max(ans, maxi[a][0]);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, b, w;
  cin >> n >> m;
  for (long long i = 0; i < n; ++i) p[i] = i;
  edges.resize(m), vec.resize(n);
  for (long long i = 0; i < m; ++i) {
    ans[i] = -1;
    cin >> a >> b >> w;
    a--, b--;
    edges[i] = {pair<long long, long long>(w, i),
                pair<long long, long long>(a, b)};
  }
  sort((edges).begin(), (edges).end());
  for (long long i = 0; i < m; ++i) {
    a = findSet(edges[i].second.first);
    b = findSet(edges[i].second.second);
    if (a == b) {
      nt.push_back(i);
      continue;
    }
    p[a] = b;
    vec[edges[i].second.first].push_back(pair<long long, long long>(
        edges[i].first.first, edges[i].second.second));
    vec[edges[i].second.second].push_back(pair<long long, long long>(
        edges[i].first.first, edges[i].second.first));
  }
  dfs(0, 0, 0);
  for (auto it : nt) {
    a = edges[it].second.first, b = edges[it].second.second;
    long long l = lca(a, b);
    ans[edges[it].first.second] = max(get_max(a, l), get_max(b, l));
  }
  for (long long i = 0; i < m; ++i) {
    if (ans[i] == -1) continue;
    cout << ans[i] << " ";
  }
  return 0;
}