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 long long MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 1e9;
long long addMod(long long a, long long b) {
  if (a + b >= MOD) return a + b - MOD;
  return a + b;
}
long long mulMod(long long a, long long b) { return (a * b) % MOD; }
long long fast(long long a, long long b) {
  if (b == 0) return 1;
  long long tmp = fast(a, b / 2);
  tmp = mulMod(tmp, tmp);
  if (b & 1) tmp = mulMod(tmp, a);
  return tmp;
}
const int N = 1e6;
const int N2 = 1e5;
int u[N + 5], v[N + 5], w[N + 5];
int n, m;
int par[N + 5];
bool flag[N + 5];
pair<int, int> sparse[20][N + 5];
vector<pair<int, int> > G[N + 5];
int dep[N + 5];
void dfs(int u, int p) {
  dep[u] = dep[p] + 1;
  for (int i = 0; i <= (int)G[u].size() - 1; i += 1) {
    int v = G[u][i].first;
    int w = G[u][i].second;
    if (v == p) {
      sparse[0][u] = make_pair(v, w);
      continue;
    }
    dfs(v, u);
  }
}
void build() {
  for (int i = 1; i <= 18; i += 1) {
    for (int j = 1; j <= n; j += 1) {
      int val = max(sparse[i - 1][j].second,
                    sparse[i - 1][sparse[i - 1][j].first].second);
      sparse[i][j] =
          make_pair(sparse[i - 1][sparse[i - 1][j].first].first, val);
    }
  }
}
int getMAX(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  int ta, tb, ret = 0, val1, val2;
  for (int i = (int)18 - 1; i >= 0; i -= 1) {
    tb = sparse[i][b].first;
    val2 = sparse[i][b].second;
    if (dep[tb] >= dep[a]) {
      b = tb;
      ret = max(ret, val2);
    }
  }
  if (b == a) return ret;
  for (int i = (int)18 - 1; i >= 0; i -= 1) {
    ta = sparse[i][a].first;
    val1 = sparse[i][a].second;
    tb = sparse[i][b].first;
    val2 = sparse[i][b].second;
    if (ta != tb) {
      a = ta, b = tb;
      ret = max(ret, val1);
      ret = max(ret, val2);
    }
  }
  ret = max(ret, sparse[0][a].second);
  ret = max(ret, sparse[0][b].second);
  return ret;
}
int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
void MST() {
  priority_queue<pair<pair<int, int>, pair<int, int> > > pq;
  while (!pq.empty()) pq.pop();
  for (int i = 1; i <= n; i += 1) par[i] = i;
  for (int i = 0; i <= (int)m - 1; i += 1) {
    pq.push(make_pair(make_pair(-w[i], i), make_pair(u[i], v[i])));
  }
  int uu, vv, pu, pv, id, ww;
  while (!pq.empty()) {
    ww = -pq.top().first.first;
    uu = pq.top().second.first;
    vv = pq.top().second.second;
    id = pq.top().first.second;
    pq.pop();
    pu = find(uu);
    pv = find(vv);
    if (pu != pv) {
      par[pu] = pv;
      flag[id] = true;
      G[uu].push_back(make_pair(vv, ww));
      G[vv].push_back(make_pair(uu, ww));
    }
  }
}
void solve() {
  memset(flag, 0, sizeof flag);
  for (int i = 0; i <= (int)19 - 1; i += 1) {
    for (int j = 0; j <= (int)n + 3 - 1; j += 1) sparse[i][j] = make_pair(0, 0);
  }
  MST();
  dep[0] = 0;
  dfs(1, 0);
  build();
  for (int i = 0; i <= (int)m - 1; i += 1) {
    if (flag[i]) continue;
    printf("%d\n", getMAX(u[i], v[i]));
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i <= (int)m - 1; i += 1) {
    scanf("%d %d %d", &u[i], &v[i], &w[i]);
  }
  solve();
  return 0;
}