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<int> g[100006], gw[100006];
struct edge {
  int u, v, w, idx;
};
bool cmp(edge a, edge b) { return a.w < b.w; }
int fa[100006];
int n, m, sum = 0;
edge edges[1000006];
int find(int n) { return (fa[n] == n ? n : (fa[n] = find(fa[n]))); }
bool book[1000006];
void kruskal() {
  for (int i = 0; i < n + 1; ++i) fa[i] = i;
  sort(edges, edges + m, cmp);
  for (int i = 0; i < m; ++i) {
    if (find(edges[i].u) != find(edges[i].v)) {
      int u = edges[i].u, v = edges[i].v;
      g[u].push_back(v), g[v].push_back(u);
      gw[u].push_back(edges[i].w), gw[v].push_back(edges[i].w);
      fa[find(edges[i].u)] = fa[find(edges[i].v)];
      ;
      book[i] = true;
    }
  }
  return;
}
int G[100006][20][2], h[100006];
bool done[100006];
void dfs(int u, int f) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i], w = gw[u][i];
    if (v == f) continue;
    h[v] = h[u] + 1;
    G[v][0][0] = u, G[v][0][1] = w;
    for (int j = 1; j < 20; ++j)
      if (G[G[v][j - 1][0]][j - 1][0]) {
        G[v][j][0] = G[G[v][j - 1][0]][j - 1][0],
        G[v][j][1] = max(G[v][j - 1][1], G[G[v][j - 1][0]][j - 1][1]);
      } else
        break;
    dfs(v, u);
  }
}
int lca(int a, int b) {
  int l = (h[a] > h[b] ? a : b), r = (h[a] > h[b] ? b : a);
  int suml = 0, sumr = 0;
  if (h[a] != h[b]) {
    for (int i = 19; i >= 0; --i)
      if (h[G[l][i][0]] >= h[r]) {
        suml = max(suml, G[l][i][1]);
        l = G[l][i][0];
      }
  }
  if (l == r) return max(suml, sumr);
  for (int i = 19; i >= 0; --i)
    if (G[l][i][0] != G[r][i][0]) {
      suml = max(suml, G[l][i][1]), sumr = max(G[r][i][1], sumr);
      l = G[l][i][0], r = G[r][i][0];
    }
  suml = max(suml, G[l][0][1]), sumr = max(G[r][0][1], sumr);
  return max(suml, sumr);
}
int res[1000006];
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    static int u, v, w;
    cin >> u >> v >> w;
    edges[i].u = u, edges[i].v = v, edges[i].w = w, edges[i].idx = i;
  }
  kruskal();
  h[1] = 1;
  dfs(1, 1);
  int ans;
  for (int i = 0; i < m; ++i)
    if (!book[i]) {
      ans = lca(edges[i].u, edges[i].v), res[edges[i].idx] = ans;
    } else
      res[edges[i].idx] = -1;
  for (int i = 0; i < m; ++i)
    if (~res[i]) printf("%d ", res[i]);
  return 0;
}