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 int N = 1e5;
pair<int, pair<int, int> > li[10 * N + 5];
int urut[10 * N + 5];
int par[N + 5];
bool cmp(int x, int y) { return li[x].first < li[y].first; }
int n, m;
int find_par(int x) {
  if (par[x] == x) return x;
  return par[x] = find_par(par[x]);
}
priority_queue<pair<int, pair<pair<int, pair<int, int> >, int> > > pq;
int ans[10 * N + 5];
bool cek(int x) {
  for (int i = 1; i <= n; i++) par[i] = i;
  int cnt = 1;
  for (int i = 2; i <= m; i++) {
    if (li[i].first >= x) {
      int pa = find_par(li[1].second.first);
      int pb = find_par(li[1].second.second);
      if (pa != pb) return 1;
    }
    int pa = find_par(li[i].second.first);
    int pb = find_par(li[i].second.second);
    if (pa == pb) continue;
    par[pa] = pb;
    cnt++;
  }
  if (cnt != n) return 1;
  return 0;
}
int main() {
  memset(ans, -1, sizeof(ans));
  scanf("%d%d", &n, &m);
  if (m == n - 1) {
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &li[i].second.first, &li[i].second.second, &li[i].first);
    urut[i] = i;
  }
  sort(urut + 1, urut + m + 1, cmp);
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= m; i++) {
    int pa = find_par(li[urut[i]].second.first);
    int pb = find_par(li[urut[i]].second.second);
    if (pa == pb) {
      pq.push(make_pair(0, make_pair(make_pair(-(1 + li[urut[i]].first) / 2,
                                               make_pair(1, li[urut[i]].first)),
                                     urut[i])));
      ans[urut[i]] = 0;
      continue;
    }
    par[pa] = pb;
  }
  for (int k = 0; k < 30; k++) {
    for (int i = 1; i <= n; i++) par[i] = i;
    for (int i = 1; i <= m; i++) {
      while (!pq.empty() && -pq.top().second.first.first <= li[urut[i]].first &&
             pq.top().first == -k) {
        int pa = find_par(li[pq.top().second.second].second.first);
        int pb = find_par(li[pq.top().second.second].second.second);
        pair<int, pair<pair<int, pair<int, int> >, int> > tmp = pq.top();
        pq.pop();
        tmp.first--;
        if (pa != pb) {
          ans[tmp.second.second] = -tmp.second.first.first;
          tmp.second.first.second.first = -tmp.second.first.first + 1;
          if (tmp.second.first.second.first > tmp.second.first.second.second)
            continue;
          tmp.second.first.first = -(tmp.second.first.second.first +
                                     tmp.second.first.second.second) /
                                   2;
          pq.push(tmp);
        } else {
          tmp.second.first.second.second = -tmp.second.first.first - 1;
          if (tmp.second.first.second.first > tmp.second.first.second.second)
            continue;
          tmp.second.first.first = -(tmp.second.first.second.first +
                                     tmp.second.first.second.second) /
                                   2;
          pq.push(tmp);
        }
      }
      int pa = find_par(li[urut[i]].second.first);
      int pb = find_par(li[urut[i]].second.second);
      if (pa == pb) {
        continue;
      }
      par[pa] = pb;
    }
    while (!pq.empty() && pq.top().first == -k) {
      pair<int, pair<pair<int, pair<int, int> >, int> > tmp = pq.top();
      pq.pop();
      tmp.first--;
      tmp.second.first.second.second = -tmp.second.first.first - 1;
      if (tmp.second.first.second.first > tmp.second.first.second.second)
        continue;
      tmp.second.first.first =
          -(tmp.second.first.second.first + tmp.second.first.second.second) / 2;
      pq.push(tmp);
    }
  }
  bool spas = 0;
  for (int i = 1; i <= m; i++) {
    if (ans[i] == -1) continue;
    printf("%d\n", ans[i]);
  }
  return 0;
}