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 int MN = 1e5;
int pa[MN + 1], de[MN + 1];
void Init() {
  for (int i = 1; i <= MN; i++) de[pa[i] = i] = 1;
}
int Find(int x) { return x == pa[x] ? x : pa[x] = Find(pa[x]); }
void Union(int x, int y) {
  x = Find(x);
  y = Find(y);
  if (x != y) {
    if (de[x] < de[y]) swap(x, y);
    pa[y] = x;
    if (de[x] == de[y]) de[x]++;
  }
}
int ans[1000001];
struct E {
  int u, v, w, idx;
  bool operator<(const E& rhs) const { return w < rhs.w; }
} e[1000001];
vector<pair<int, int> > edge[100001];
const int MAXLOG = 18, MAXN = 1e5;
int parent[MAXLOG + 1][MAXN + 1], depth[MAXN + 1], d[MAXLOG + 1][MAXN + 1];
void dfs(int index, int father, int len) {
  parent[0][index] = father;
  d[0][index] = len;
  for (int i = 0; i + 1 <= MAXLOG; i++) {
    parent[i + 1][index] = parent[i][parent[i][index]];
    d[i + 1][index] = max(d[i][index], d[i][parent[i][index]]);
  }
  for (int i = 0; i < edge[index].size(); i++) {
    int next = edge[index][i].first;
    if (next == father) continue;
    depth[next] = depth[index] + 1;
    dfs(next, index, edge[index][i].second);
  }
}
int LCA(int a, int b) {
  int res = 0;
  if (depth[a] > depth[b]) swap(a, b);
  int k = 0;
  for (int i = depth[b] - depth[a]; i; i /= 2) {
    if (i % 2) {
      res = max(res, d[k][b]);
      b = parent[k][b];
    }
    k++;
  }
  if (a == b) return res;
  for (int i = MAXLOG; i >= 0; i--)
    if (parent[i][a] != parent[i][b]) {
      res = max(res, d[i][a]);
      a = parent[i][a];
      res = max(res, d[i][b]);
      b = parent[i][b];
    }
  return max(max(res, d[0][a]), d[0][b]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  Init();
  for (int i = 1; i <= m; i++) {
    cin >> e[i].u >> e[i].v >> e[i].w;
    e[i].idx = i;
  }
  sort(e + 1, e + 1 + m);
  for (int i = 1; i <= m; i++)
    if (Find(e[i].u) != Find(e[i].v)) {
      Union(e[i].u, e[i].v);
      ans[e[i].idx] = -1;
      edge[e[i].u].emplace_back(make_pair(e[i].v, e[i].w));
      edge[e[i].v].emplace_back(make_pair(e[i].u, e[i].w));
    }
  dfs(1, 0, 0);
  for (int i = 1; i <= m; i++) {
    if (ans[e[i].idx] != -1) {
      ans[e[i].idx] = LCA(e[i].u, e[i].v);
    }
  }
  for (int i = 1; i <= m; i++)
    if (ans[i] != -1) cout << ans[i] << '\n';
}