#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using i64 = int64_t; using i32 = int32_t; template void init_n(vector& v, size_t n, U x) { v = vector(n, x); } template void init_n(vector& v, size_t n) { init_n(v, n, T()); } template void read_n(vector& v, size_t n, size_t o = 0) { v = vector(n+o); for (size_t i=o; i> v[i]; } template void read_n(T a[], size_t n, size_t o = 0) { for (size_t i=o; i> a[i]; } template T gabs(const T& x) { return max(x, -x); } #define abs gabs i64 n, m; vector>> g; vector> dp; i64 dfs(i64 u, i64 s) { if (dp[u][s] >= 0) return dp[u][s]; s |= 1 << (u - 1); i64 y = 0; for (const auto& p : g[u]) { i64 c, v; tie(c, v) = p; if (!(s & (1 << (v - 1)))) { y = max(y, c + dfs(v, s)); } } return dp[u][s] = y; } int main() { cin >> n >> m; init_n(g, n + 1); for (i64 i = 0; i < m; ++i) { i64 a, b, c; cin >> a >> b >> c; g[a].emplace_back(c, b); g[b].emplace_back(c, a); } for (i64 u = 1; u <= n; ++u) { sort(begin(g[u]), end(g[u]), greater>()); } init_n(dp, n + 1, vector(1 << n, -1)); for (i64 u = 1; u <= n; ++u) { dfs(u, 0); } i64 ans = 0; for (i64 u = 1; u <= n; ++u) { for (i64 d : dp[u]) ans = max(ans, d); } cout << ans << '\n'; return 0; }