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>
#pragma GCC optimize(2)
using namespace std;
const long long inff = 0x3f3f3f3f3f3f3f3f;
const int N = 200008;
int deep[N], fa[N][20], n, m, st[N][20], f[N], ans[1000008];
vector<pair<int, int> > g[N];
struct as {
  int x, y, z, id;
} a[1000008];
void dfs(int u, int f) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (v == f) continue;
    deep[v] = deep[u] + 1, dfs(v, u), fa[v][0] = u, st[v][0] = g[u][i].second;
  }
}
void bz() {
  for (int i(1); i <= (18); ++i)
    for (int j(1); j <= (n); ++j)
      fa[j][i] = fa[fa[j][i - 1]][i - 1],
      st[j][i] = max(st[j][i - 1], st[fa[j][i - 1]][i - 1]);
}
int lca(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  int d = deep[x] - deep[y], ans = 0;
  for (int i(0); i <= (18); ++i)
    if (d & (1 << i)) ans = max(st[x][i], ans), x = fa[x][i];
  if (x == y) return ans;
  for (int i(18); i >= (0); --i)
    if (fa[x][i] != fa[y][i])
      ans = max(st[x][i], ans), ans = max(st[y][i], ans), x = fa[x][i],
      y = fa[y][i];
  return max(ans, max(st[x][0], st[y][0]));
}
bool cmp(as a, as b) { return a.z < b.z; }
int fid(int x) {
  int a = x, b;
  while (a != f[a]) a = f[a];
  while (x != f[x]) b = f[x], f[x] = a, x = b;
  return a;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i(1); i <= (n); ++i) f[i] = i;
  for (int i(1); i <= (m); ++i)
    scanf("%d", &a[i].x), scanf("%d", &a[i].y), scanf("%d", &a[i].z),
        a[i].id = i;
  sort(a + 1, a + m + 1, cmp);
  for (int i(1); i <= (m); ++i) {
    int fx = fid(a[i].x), fy = fid(a[i].y);
    if (fx == fy) {
      ans[a[i].id] = i;
      continue;
    }
    f[fx] = fy;
    g[a[i].x].push_back(pair<int, int>(a[i].y, a[i].z));
    g[a[i].y].push_back(pair<int, int>(a[i].x, a[i].z));
  }
  dfs(1, 0), bz();
  for (int i(1); i <= (m); ++i)
    if (ans[i]) printf("%d\n", lca(a[ans[i]].x, a[ans[i]].y));
  return 0;
}