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;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
inline bool char_read() {
  char ch = getchar();
  while (!isalpha(ch)) return -1;
  return ch == 'B' ? 0 : 1;
}
void Write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) Write(x / 10);
  putchar(x % 10 + 48);
}
inline void writes(long long x) { Write(x), putchar(' '); }
inline void Writes(long long x) { Write(x), putchar('\n'); }
int n, m;
int fa[205000], size[205000];
bool vis[2006000];
struct node {
  int x, y, z, id;
} E[2006000];
int head[205000], deg[205000], nxt[2006000], ver[2006000], edge[2006000],
    tot = 1;
int f[205000][22], maxn[205000][22], dep[205000];
queue<int> q;
void add(int x, int y, int z) {
  ver[++tot] = y, nxt[tot] = head[x], head[x] = tot, edge[tot] = z;
}
bool cmp(const node &a, const node &b) { return a.z < b.z; }
bool ccmp(const node &a, const node &b) { return a.id < b.id; }
void Start() {
  for (int i = 1; i <= n; ++i) fa[i] = i;
}
int Get(int x) { return x == fa[x] ? x : fa[x] = Get(fa[x]); }
void Merge(int x, int y) { x = Get(x), y = Get(y), fa[x] = y; }
void Treat() {
  q.push(1), dep[1] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = nxt[i]) {
      int y = ver[i];
      if (dep[y]) continue;
      dep[y] = dep[x] + 1, q.push(y), f[y][0] = x, maxn[y][0] = edge[i];
      for (int j = 1; j < 22; ++j)
        f[y][j] = f[f[y][j - 1]][j - 1],
        maxn[y][j] = max(maxn[y][j - 1], maxn[f[y][j - 1]][j - 1]);
    }
  }
}
int GetMax(int x, int y) {
  int tmax = 0;
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 22 - 1; i >= 0; --i)
    if (dep[f[x][i]] >= dep[y]) tmax = max(maxn[x][i], tmax), x = f[x][i];
  if (x == y) return tmax;
  for (int i = 22 - 1; i >= 0; --i)
    if (f[x][i] != f[y][i])
      tmax = max(maxn[x][i], tmax), tmax = max(maxn[y][i], tmax), x = f[x][i],
      y = f[y][i];
  tmax = max(tmax, maxn[x][0]), tmax = max(tmax, maxn[y][0]);
  return tmax;
}
signed main() {
  n = read(), m = read();
  for (int i = 1, x, y, z; i <= m; ++i)
    x = read(), y = read(), z = read(), E[i] = (node){x, y, z, i};
  sort(E + 1, E + 1 + m, cmp);
  Start();
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y, z = E[i].z, id = E[i].id;
    if (Get(x) == Get(y)) continue;
    Merge(x, y), vis[id] = 1;
    add(x, y, z), add(y, x, z);
  }
  Treat();
  sort(E + 1, E + 1 + m, ccmp);
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y, z = E[i].z, id = E[i].id;
    if (vis[id]) continue;
    Writes(GetMax(x, y));
  }
  return 0;
}