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 maxn = 100050;
const long long mod = 1e9 + 7;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int f[maxn];
int findf(int x) { return f[x] == x ? x : f[x] = findf(f[x]); }
struct edge {
  int u;
  int v;
  long long w;
  int id;
  friend bool operator<(edge a, edge b) { return a.w < b.w; }
} e[maxn * 10];
bool chs[maxn * 10];
bool cmp(edge a, edge b) { return a.id < b.id; }
int dep[maxn];
int fa[maxn][25];
long long fw[maxn][25];
struct te {
  int v;
  long long w;
} now, nxt;
vector<te> g[maxn];
void dfs(int x, int p) {
  int k = 0;
  while (fa[x][k] && fa[fa[x][k]][k]) {
    fa[x][k + 1] = fa[fa[x][k]][k];
    fw[x][k + 1] = max(fw[x][k], fw[fa[x][k]][k]);
    k++;
  }
  int sz = g[x].size();
  int v = 0;
  for (int i = 0; i <= sz - 1; i++) {
    v = g[x][i].v;
    if (v == p) continue;
    fa[v][0] = x;
    fw[v][0] = g[x][i].w;
    dep[v] = dep[x] + 1;
    dfs(v, x);
  }
}
long long getans(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  long long mx = 0;
  int k = 0, dif = dep[u] - dep[v];
  int ru = u, rv = v;
  while (dif) {
    if (dif & 1) {
      mx = max(fw[u][k], mx);
      u = fa[u][k];
    }
    dif >>= 1;
    k++;
  }
  if (u == v) return mx;
  k = 0;
  while (k >= 0) {
    if (fa[u][k] != fa[v][k]) {
      mx = max(mx, fw[u][k]);
      mx = max(mx, fw[v][k]);
      u = fa[u][k];
      v = fa[v][k];
      k++;
    } else {
      k--;
    }
  }
  mx = max(mx, fw[u][0]);
  mx = max(mx, fw[v][0]);
  return mx;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    e[i].u = read();
    e[i].v = read();
    e[i].w = read();
    e[i].id = i;
  }
  for (int i = 1; i <= n; i++) {
    f[i] = i;
  }
  sort(e + 1, e + 1 + m);
  for (int i = 1; i <= m; i++) {
    int u = e[i].u;
    int v = e[i].v;
    int fu = findf(u), fv = findf(v);
    if (fu == fv) continue;
    f[fu] = fv;
    chs[e[i].id] = true;
    now.w = e[i].w;
    now.v = v;
    g[u].push_back(now);
    now.v = u;
    g[v].push_back(now);
  }
  dfs(1, 0);
  sort(e + 1, e + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    if (chs[i]) continue;
    printf("%I64d\n", getans(e[i].u, e[i].v));
  }
  return 0;
}