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;
int getint() {
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  int t = c - 48;
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) t = t * 10 + c - 48;
  return t;
}
void putint(long long n) {
  char a[20];
  int size = 0;
  if (n == 0) putchar('0');
  while (n) {
    a[size++] = n % 10 + 48;
    n /= 10;
  }
  for (int i = size - 1; i >= 0; i--) putchar(a[i]);
  putchar('\n');
}
int n, m, x, y, z, fa[300000], anc[300000][20], depth[300000];
vector<pair<int, int> > a[300000];
pair<pair<int, int>, pair<int, int> > e[2000000];
bool b[2000000];
long long mst, ans[2000000], cost[300000][20];
int getf(int x) {
  if (x == fa[x])
    return x;
  else {
    fa[x] = getf(fa[x]);
    return fa[x];
  }
}
void dfs(int x, int l) {
  for (int i = 0; i < a[x].size(); i++)
    if (l != a[x][i].first) {
      anc[a[x][i].first][0] = x;
      cost[a[x][i].first][0] = a[x][i].second;
      depth[a[x][i].first] = depth[x] + 1;
      dfs(a[x][i].first, x);
    }
}
void init() {
  for (int k = 1; k < 20; k++)
    for (int i = 1; i <= n; i++) {
      if (anc[i][k - 1] == 0) continue;
      anc[i][k] = anc[anc[i][k - 1]][k - 1];
      cost[i][k] = max(cost[i][k - 1], cost[anc[i][k - 1]][k - 1]);
    }
}
long long get(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  long long t = 0;
  for (int k = 19; k >= 0; k--) {
    if (anc[u][k] == 0) continue;
    if (depth[anc[u][k]] >= depth[v]) {
      t = max(t, cost[u][k]);
      u = anc[u][k];
      if (depth[u] == depth[v]) break;
    }
  }
  if (u == v) return t;
  for (int k = 19; k >= 0; k--) {
    if (anc[u][k] == 0) continue;
    if (anc[u][k] != anc[v][k]) {
      t = max(t, max(cost[u][k], cost[v][k]));
      u = anc[u][k];
      v = anc[v][k];
    }
  }
  return max(t, max(cost[u][0], cost[v][0]));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    x = getint();
    y = getint();
    z = getint();
    e[i] = make_pair(make_pair(z, i), make_pair(x, y));
  }
  sort(e + 1, e + m + 1);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    x = getf(e[i].second.first);
    y = getf(e[i].second.second);
    if (x == y) continue;
    mst += e[i].first.first;
    b[i] = true;
    a[e[i].second.first].push_back(
        make_pair(e[i].second.second, e[i].first.first));
    a[e[i].second.second].push_back(
        make_pair(e[i].second.first, e[i].first.first));
    fa[x] = y;
  }
  depth[1] = 1;
  dfs(1, 0);
  init();
  for (int i = 1; i <= m; i++) {
    ans[e[i].first.second] = mst;
    if (b[i]) {
      ans[e[i].first.second] = -1;
      continue;
    }
    ans[e[i].first.second] = get(e[i].second.first, e[i].second.second);
  }
  for (int i = 1; i <= m; i++)
    if (ans[i] != -1) printf("%lld\n", ans[i]);
  return 0;
}