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 MOD = 1000000007;
vector<pair<pair<long long, long long>, pair<long long, long long> > > vec,
    edges;
long long p[100005], up[100005][18], maxi[100005][18];
long long in[100005], out[100005], t = 0;
long long find(long long i) {
  if (p[i] == i) return i;
  return p[i] = find(p[i]);
}
vector<vector<pair<long long, long long> > > MST;
vector<bool> used;
vector<long long> ans, id;
void dfs(long long node, long long p, long long dist) {
  in[node] = ++t;
  up[node][0] = p;
  maxi[node][0] = dist;
  for (long long i = 1; i < 18; i++) up[node][i] = up[up[node][i - 1]][i - 1];
  for (long long i = 1; i < 18; i++)
    maxi[node][i] = max(maxi[node][i - 1], maxi[up[node][i - 1]][i - 1]);
  for (auto child : MST[node]) {
    if (child.first == p) continue;
    dfs(child.first, node, child.second);
  }
  out[node] = ++t;
}
bool isansces(long long i, long long j) {
  return (in[i] <= in[j] && out[j] <= out[i]);
}
long long lca(long long a, long long b) {
  if (isansces(a, b)) return a;
  if (isansces(b, a)) return b;
  for (long long i = 17; i >= 0; i--)
    if (!isansces(up[b][i], a)) b = up[b][i];
  return up[b][0];
}
long long get_max(long long lc, long long a) {
  if (a == lc) return 0;
  long long Ans = 0;
  for (long long i = 17; i >= 0; i--)
    if (!isansces(up[a][i], lc)) {
      Ans = max(Ans, maxi[a][i]);
      a = up[a][i];
    }
  return max(maxi[a][0], Ans);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  MST.resize(n);
  vec.resize(m), edges.resize(m), used.resize(m), ans.resize(m);
  for (long long i = 0; i < m; ++i) {
    cin >> vec[i].second.first >> vec[i].second.second >> vec[i].first.first;
    vec[i].first.second = i;
    vec[i].second.first--, vec[i].second.second--;
    edges[i] = vec[i];
  }
  for (long long i = 0; i < n; ++i) p[i] = i;
  sort((vec).begin(), (vec).end());
  for (long long i = 0; i < m; ++i) {
    long long x = find(vec[i].second.first), y = find(vec[i].second.second);
    if (x != y) {
      p[x] = y;
      MST[vec[i].second.first].push_back(
          pair<long long, long long>(vec[i].second.second, vec[i].first.first));
      MST[vec[i].second.second].push_back(
          pair<long long, long long>(vec[i].second.first, vec[i].first.first));
    } else
      id.push_back(vec[i].first.second);
  }
  sort((id).begin(), (id).end());
  dfs(0, 0, 0);
  for (long long i = 0; i < (long long)id.size(); ++i) {
    long long LC = lca(edges[id[i]].second.first, edges[id[i]].second.second);
    cout << max(get_max(LC, edges[id[i]].second.first),
                get_max(LC, edges[id[i]].second.second))
         << "\n";
  }
  return 0;
}