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 + 1;
const int M = 1e6 + 1;
struct oneEdge {
  int from;
  int to;
  int power;
  int number;
};
inline bool cmp(oneEdge a, oneEdge b) { return a.power < b.power; }
oneEdge edge[M], edge2[M];
vector<int> span;
vector<pair<int, int> > spanningTree[N];
int n, m, king[N], maxPower[20][N], father[20][N], depth[N], ans[M];
bool inSpanningTree[M];
void read() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].from >> edge[i].to >> edge[i].power;
    edge[i].number = i;
    edge2[i] = edge[i];
  }
  return;
}
int getKing(int v) {
  if (v == king[v]) {
    return v;
  } else {
    return king[v] = getKing(king[v]);
  }
}
void prepare() {
  for (int i = 1; i <= n; i++) {
    king[i] = i;
  }
  return;
}
void createSpanningTree() {
  sort(edge + 1, edge + m + 1, cmp);
  prepare();
  for (int i = 1; i <= m; i++) {
    int king1 = getKing(edge[i].from);
    int king2 = getKing(edge[i].to);
    if (king1 != king2) {
      king[king1] = king2;
      spanningTree[edge[i].from].push_back({edge[i].to, edge[i].power});
      spanningTree[edge[i].to].push_back({edge[i].from, edge[i].power});
      inSpanningTree[edge[i].number] = 1;
    }
  }
  return;
}
void dfs(int v, int father = 0) {
  depth[v] = depth[father] + 1;
  for (int i = 0; i < spanningTree[v].size(); i++) {
    if (spanningTree[v][i].first == father) {
      continue;
    }
    maxPower[0][spanningTree[v][i].first] = spanningTree[v][i].second;
    ::father[0][spanningTree[v][i].first] = v;
    dfs(spanningTree[v][i].first, v);
  }
  return;
}
void createDP() {
  dfs(1);
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      if (father[i - 1][father[i - 1][j]] == 0) {
        continue;
      } else {
        father[i][j] = father[i - 1][father[i - 1][j]];
        maxPower[i][j] =
            max(maxPower[i - 1][j], maxPower[i - 1][father[i - 1][j]]);
      }
    }
  }
  return;
}
int toSameDepth(int downer, int upper, int& ans) {
  for (int i = 19; i >= 0; i--) {
    if (depth[father[i][downer]] < depth[upper]) {
      continue;
    }
    ans = max(ans, maxPower[i][downer]);
    downer = father[i][downer];
  }
  return downer;
}
void calcAnswer(int v1, int v2, int& ans) {
  for (int i = 19; i >= 0; i--) {
    if (father[i][v1] == father[i][v2]) {
      continue;
    }
    ans = max(ans, maxPower[i][v1]);
    ans = max(ans, maxPower[i][v2]);
    v1 = father[i][v1];
    v2 = father[i][v2];
  }
  if (v1 != v2) {
    ans = max(ans, maxPower[0][v1]);
    ans = max(ans, maxPower[0][v2]);
  }
  return;
}
int getAnswer(int v1, int v2) {
  int ans = 0;
  if (depth[v1] > depth[v2]) {
    v1 = toSameDepth(v1, v2, ans);
  } else if (depth[v2] > depth[v1]) {
    v2 = toSameDepth(v2, v1, ans);
  }
  calcAnswer(v1, v2, ans);
  return ans;
}
void getAnswers() {
  for (int i = 1; i <= m; i++) {
    if (inSpanningTree[i]) {
      continue;
    }
    ans[i] = getAnswer(edge2[i].from, edge2[i].to);
  }
  return;
}
void write() {
  for (int i = 1; i <= m; i++) {
    if (inSpanningTree[i]) {
      continue;
    }
    cout << ans[i] << "\n";
  }
  return;
}
void solve() {
  read();
  createSpanningTree();
  createDP();
  getAnswers();
  write();
  return;
}
int main() {
  solve();
  return 0;
}