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 maxn = 1e5 + 1, maxint = 1e9;
struct edge {
  long long u, v, w, st;
};
edge a[maxn * 10];
long long n, m, p[maxn], mark[maxn * 10], sp[20][maxn], spv[20][maxn], h[maxn],
    aans[maxn * 10];
vector<pair<long long, long long> > G[maxn];
void read() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++)
    scanf("%I64d %I64d %I64d", &a[i].u, &a[i].v, &a[i].w), a[i].st = i;
}
bool cmp(edge t1, edge t2) { return t1.w < t2.w; }
int findroot(int u) {
  while (p[u] > 0) u = p[u];
  return u;
}
void megh(int u, int v) {
  if (p[u] < p[v])
    p[v] = u;
  else if (p[v] < p[u])
    p[u] = v;
  else {
    p[v] = u;
    p[u]--;
  }
}
void mst() {
  int t = 0;
  for (int i = 1; i <= m && t < n; i++) {
    int u = a[i].u, v = a[i].v, w = a[i].w, ru = findroot(u), rv = findroot(v);
    if (ru != rv) {
      t++;
      megh(ru, rv);
      G[u].push_back({v, w});
      G[v].push_back({u, w});
      mark[i] = 1;
      aans[a[i].st] = -1;
    }
  }
}
void dfs(int u, int k) {
  h[u] = k;
  for (int i = 0; i < G[u].size(); i++)
    if (!sp[0][G[u][i].first] && G[u][i].first != 1) {
      int v = G[u][i].first, w = G[u][i].second;
      sp[0][v] = u;
      spv[0][v] = w;
      dfs(v, k + 1);
    }
}
pair<long long, long long> findp(int u, int k) {
  long long ans = -maxint;
  for (int i = 0; k; i++, k /= 2)
    if (k & 1) {
      ans = max(ans, spv[i][u]);
      u = sp[i][u];
    }
  return {u, ans};
}
long long lca(int u, int v) {
  int tmp = min(h[u], h[v]);
  pair<long long, long long> pu = findp(u, h[u] - tmp),
                             pv = findp(v, h[v] - tmp);
  long long ans = max(pu.second, pv.second), k = 17;
  u = pu.first, v = pv.first;
  while (u != v) {
    while (k && sp[k][u] == sp[k][v]) k--;
    ans = max(ans, max(spv[k][u], spv[k][v]));
    u = sp[k][u];
    v = sp[k][v];
  }
  return ans;
}
void process() {
  sort(a + 1, a + m + 1, cmp);
  mst();
  for (int k = 1; k <= 17; k++)
    for (int i = 1; i <= n; i++) spv[k][i] = -maxint;
  dfs(1, 1);
  for (int k = 1; k <= 17; k++)
    for (int i = 1; i <= n; i++) {
      sp[k][i] = sp[k - 1][sp[k - 1][i]];
      spv[k][i] = max(spv[k - 1][i], spv[k - 1][sp[k - 1][i]]);
    }
  for (int i = 1; i <= m; i++)
    if (!mark[i]) {
      long long tmp = lca(a[i].u, a[i].v);
      aans[a[i].st] = tmp;
    }
  for (int i = 1; i <= m; i++)
    if (aans[i] != -1) printf("%I64d \n", aans[i]);
}
int main() {
  read();
  process();
  return 0;
}