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 max_n = 100010;
int par[max_n], Rank[max_n];
int find(int v) {
  if (v == par[v]) return v;
  return par[v] = find(par[v]);
}
void unite(int u, int v) {
  if (find(u) == find(v)) return;
  int x = find(u), y = find(v);
  if (Rank[x] >= Rank[y]) {
    par[y] = x;
    if (Rank[y] == Rank[x]) Rank[x]++;
  } else
    par[x] = y;
}
struct Edge {
  int from, to, nol;
  long long len;
};
struct cmp {
  bool operator()(Edge A, Edge B) { return A.len < B.len; }
};
vector<Edge> E;
vector<pair<long long, long long> > G[max_n];
int n, m;
int Tree[max_n * 10] = {0};
pair<long long, long long> Ver[max_n * 10];
void MST() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    Rank[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int u, v, len;
    scanf("%d%d%d", &u, &v, &len);
    E.push_back({u, v, i, len});
    Ver[i] = {u, v};
  }
  sort(E.begin(), E.end(), cmp());
  for (Edge e : E) {
    int u = e.from, v = e.to;
    if (find(u) != find(v)) {
      G[u].push_back({v, e.len});
      G[v].push_back({u, e.len});
      Tree[e.nol] = 1;
      unite(u, v);
    }
  }
}
long long Par[20][max_n], Dis[20][max_n];
int Depth[max_n];
void dfs(int v, int p, int d) {
  Depth[v] = d;
  Par[0][v] = p;
  for (auto u : G[v]) {
    if (u.first != p) {
      Dis[0][u.first] = u.second;
      dfs(u.first, v, d + 1);
    }
  }
}
void INIT() {
  Dis[0][1] = 0;
  dfs(1, -1, 0);
  for (int k = 0; k < 19; k++) {
    for (int v = 1; v <= n; v++) {
      if (Par[k][v] < 0) {
        Par[k + 1][v] = -1;
        Dis[k + 1][v] = Dis[k][v];
      } else {
        Par[k + 1][v] = Par[k][Par[k][v]];
        Dis[k + 1][v] = max(Dis[k][v], Dis[k][Par[k][v]]);
      }
    }
  }
}
long long LCA(int u, int v) {
  long long res = 0;
  if (Depth[v] < Depth[u]) swap(u, v);
  for (int i = 0; i < 20; i++) {
    if ((Depth[v] - Depth[u]) >> i & 1) {
      res = max(res, Dis[i][v]);
      v = Par[i][v];
    }
  }
  if (u == v) return res;
  for (int i = 19; i >= 0; i--) {
    if (Par[i][u] != Par[i][v]) {
      res = max(Dis[i][u], res);
      res = max(Dis[i][v], res);
      u = Par[i][u];
      v = Par[i][v];
    }
  }
  res = max(res, Dis[0][v]);
  res = max(res, Dis[0][u]);
  return res;
}
int main() {
  MST();
  INIT();
  for (int i = 1; i <= m; i++) {
    if (!Tree[i]) {
      int u = Ver[i].first, v = Ver[i].second;
      printf("%d\n", LCA(u, v));
    }
  }
  return 0;
}