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 FileIO() {}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int n, m;
const int N = 100005, M = 2000005;
int X, Y, Z;
int head[N], cnt;
struct e {
  int t, next, w;
} edge[M];
struct node {
  int f, t, w, id;
  bool operator<(const node& no) const { return w < no.w; }
} eg[M], Edge[M];
int fa[N], vis[M];
int findroot(int x) {
  if (fa[x] == x) return x;
  return fa[x] = findroot(fa[x]);
}
bool merge(int x, int y) {
  int fax = findroot(x);
  int fay = findroot(y);
  if (fax != fay) {
    fa[fax] = fay;
    return true;
  }
  return false;
}
void add(int f, int t, int w) {
  edge[cnt].t = t;
  edge[cnt].w = w;
  edge[cnt].next = head[f];
  head[f] = cnt++;
}
void kruskal() {
  int tot = 0;
  for (int i = 1; i <= m; i++) {
    if (tot == n - 1) break;
    int u = eg[i].f, v = eg[i].t, w = eg[i].w;
    if (X == u && v == Y) continue;
    if (merge(u, v)) {
      vis[eg[i].id] = 1;
      tot += 1;
      add(u, v, w);
      add(v, u, w);
    }
  }
  if (tot != n - 1) {
    cout << 1000000000 << endl;
    exit(0);
  }
}
int dfn[N], bz[N][25], dp[N][25];
void dfs(int root, int deep) {
  dfn[root] = deep;
  for (int i = head[root]; i != -1; i = edge[i].next) {
    int v = edge[i].t, w = edge[i].w;
    if (!dfn[v]) {
      bz[v][0] = root;
      dp[v][0] = w;
      dfs(v, deep + 1);
    }
  }
}
void deal() {
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      bz[j][i] = bz[bz[j][i - 1]][i - 1];
      dp[j][i] = max(dp[j][i - 1], dp[bz[j][i - 1]][i - 1]);
    }
  }
}
int LCA(int x, int y) {
  int ans = 0;
  if (dfn[x] < dfn[y]) swap(x, y);
  for (int i = 20; i >= 0; i--) {
    if (dfn[bz[x][i]] >= dfn[y]) {
      ans = max(ans, dp[x][i]);
      x = bz[x][i];
    }
  }
  if (x == y) return ans;
  for (int i = 20; i >= 0; i--) {
    if (bz[x][i] ^ bz[y][i]) {
      ans = max(ans, dp[x][i]);
      ans = max(ans, dp[y][i]);
      x = bz[x][i];
      y = bz[y][i];
    }
  }
  ans = max(ans, dp[x][0]);
  ans = max(ans, dp[y][0]);
  return ans;
}
void Init() {
  memset(head, -1, sizeof(head)), cnt = 0;
  for (int i = 1; i <= n; i++) fa[i] = i;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  Init();
  for (int i = 1; i <= m; i++) {
    cin >> eg[i].f >> eg[i].t >> eg[i].w;
    eg[i].id = i;
    Edge[i] = eg[i];
  }
  if (m == n - 1) return 0;
  sort(eg + 1, eg + 1 + m);
  kruskal();
  dfs(1, 1);
  deal();
  for (int i = 1; i <= m; i++)
    if (!vis[i]) cout << LCA(Edge[i].f, Edge[i].t) << endl;
}