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;
vector<pair<int, pair<int, int> > > V;
vector<pair<int, int> > adj[100007];
int P[100007];
vector<pair<int, int> > T;
int parent(int v) { return P[v] = ((P[v] == v) ? (v) : parent(P[v])); }
bool same(int u, int v) { return parent(u) == parent(v); }
void join(int v, int u) {
  if (!same(u, v)) {
    P[parent(v)] = parent(u);
  }
}
int n, m;
const int MX = 100009, MXL = 18;
vector<int> v[MX];
int QN, depth[MX], par[MXL][MX];
int maxi[MXL][MX];
int sum[MX];
void Pdfs(int first, int p) {
  int nxt, C, sz = adj[first].size();
  for (int j = 0; j < sz; j++) {
    nxt = adj[first][j].first;
    if (nxt == p) continue;
    depth[nxt] = depth[first] + 1;
    par[0][nxt] = first;
    maxi[0][nxt] = adj[first][j].second;
    Pdfs(nxt, first);
  }
}
void process() {
  for (int j = 1; j < MXL; j++)
    for (int i = 1; i <= n; i++) {
      par[j][i] = par[j - 1][par[j - 1][i]];
      maxi[j][i] = max(maxi[j - 1][i], maxi[j - 1][par[j - 1][i]]);
    }
}
pair<int, int> Kth(int first, int K) {
  int node = first;
  int M = 0;
  for (int j = 0; j < MXL; j++)
    if ((K & (1 << j))) {
      M = max(M, maxi[j][node]);
      node = par[j][node];
    }
  return make_pair(node, M);
}
int LCA(int a, int b) {
  int M = 0;
  if (depth[a] > depth[b]) swap(a, b);
  pair<int, int> P = Kth(b, depth[b] - depth[a]);
  b = P.first;
  M = P.second;
  if (a == b) return M;
  for (int j = MXL - 1; j >= 0; j--)
    if (par[j][a] != par[j][b]) {
      M = max(M, max(maxi[j][a], maxi[j][b]));
      a = par[j][a], b = par[j][b];
    }
  M = max(M, max(maxi[0][a], maxi[0][b]));
  return M;
}
vector<pair<int, pair<int, int> > > X;
map<int, int> M;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) P[i] = i;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    V.push_back(make_pair(c, make_pair(a, b)));
    M[c] = i;
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < V.size(); i++) {
    int a = V[i].second.first;
    int b = V[i].second.second;
    int c = V[i].first;
    if (!same(a, b)) {
      join(a, b);
      adj[a].push_back(make_pair(b, c));
      adj[b].push_back(make_pair(a, c));
    } else {
      X.push_back(V[i]);
    }
  }
  depth[1] = 1;
  Pdfs(1, -1);
  process();
  for (int i = 0; i < X.size(); i++) {
    T.push_back(
        make_pair(M[X[i].first], LCA(X[i].second.first, X[i].second.second)));
  }
  sort(T.begin(), T.end());
  for (int i = 0; i < T.size(); i++) cout << T[i].second << " ";
  cout << endl;
  return 0;
}