cin >> n >> m; for (int i = 1; i <= m; ++i) cin >> e[i].fr >> e[i].to >> e[i].w; sort(e + 1, e + m + 1); init_fa(n); for (int i = 1; i <= m; ++i) { int u = e[i].fr, v = e[i].to, fu = find(u), fv = find(v); if (fu == fv) continue; fa[fu] = fv; G[u].push_back(v); G[v].push_back(u); } int ans = 0; for (int i = 1; i <= n; ++i) if (!dep[i]) dep[i] = 1, dfs(i, 0); for (int i = 1; i <= m; ++i) if ((dep[e[i].fr] ^ dep[e[i].to]) % 2 == 0) ans = max(ans, e[i].w); cout << ans << "\n"; return0; }