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;
void io() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int l = 18, timer = 0, level[200005];
int tout[200005], tin[200005], up[200005][20], weights[200005][20];
vector<pair<int, int>> g[200005];
struct edge {
  int u;
  int v;
  long long wt;
  int id;
  edge(int a, int b, long long c, int d) {
    u = a;
    v = b;
    wt = c;
    id = d;
  }
};
bool cmp(edge a, edge b) { return a.wt < b.wt; }
long long rnk[100005], parent[100002];
void makeset(long long id, long long x) {
  parent[id] = id;
  rnk[id] = x;
}
long long find(long long x) {
  if (x != parent[x]) parent[x] = find(parent[x]);
  return parent[x];
}
void merge(long long x, long long y) {
  long long r1 = find(x);
  long long r2 = find(y);
  if (r1 == r2) return;
  if (rnk[r1] > rnk[r2]) {
    parent[r2] = r1;
    rnk[r1] = rnk[r1] + rnk[r2];
  } else {
    parent[r1] = r2;
    rnk[r2] = rnk[r2] + rnk[r1];
  }
}
void dfs(int v, int p = 1, int pcost = 0) {
  tin[v] = timer;
  ++timer;
  up[v][0] = p;
  weights[v][0] = pcost;
  for (int i = 1; i <= l; i++) {
    up[v][i] = up[up[v][i - 1]][i - 1];
    weights[v][i] = max(weights[v][i - 1], weights[up[v][i - 1]][i - 1]);
  }
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    int cost = g[v][i].second;
    if (to == p) continue;
    level[to] = level[v] + 1;
    dfs(to, v, cost);
  }
  tout[v] = timer;
  ++timer;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int LCA(int u, int v) {
  if (is_ancestor(u, v)) return u;
  if (is_ancestor(v, u)) return v;
  for (int i = l; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
int get_best(int v, int span) {
  int ret = 0;
  for (int i = l; i >= 0; --i) {
    if (span & (1 << i)) {
      ret = max(ret, weights[v][i]);
      v = up[v][i];
    }
  }
  return ret;
}
int getHeavy(int u, int v) {
  int ans = 0;
  int x = level[u] - level[v];
  for (int i = 18; i >= 0; i--)
    if (x & (1 << i)) {
      ans = max(ans, weights[i][u]);
      u = up[i][u];
    }
  return ans;
}
int main() {
  io();
  int n, m, i, j, k;
  int res = 0;
  cin >> n >> m;
  vector<edge> e, e2;
  for (i = 0; i < m; i++) {
    int x, y, cost;
    cin >> x >> y >> cost;
    e.push_back(edge(x, y, cost, i));
    e2.push_back(edge(x, y, cost, i));
  }
  sort(e.begin(), e.end(), cmp);
  for (i = 1; i <= n; i++) {
    makeset(i, i);
  }
  map<pair<int, int>, int> mp;
  for (i = 0; i < e.size(); i++) {
    int u = e[i].u;
    int v = e[i].v;
    if (find(u) != find(v)) {
      res += e[i].wt;
      merge(u, v);
      g[u].push_back({v, e[i].wt});
      g[v].push_back({u, e[i].wt});
      mp[{u, v}]++;
    }
  }
  dfs(1, 1);
  for (i = 0; i < e2.size(); i++) {
    int x = e2[i].u;
    int y = e2[i].v;
    if (mp[{x, y}]) continue;
    int lca = LCA(x, y);
    int heaviest = max(get_best(y, level[y] - level[lca]),
                       get_best(x, level[x] - level[lca]));
    cout << heaviest << "\n";
  }
}