#include int main() { int N, M; scanf("%d%d", &N, &M); using vi = std::vector; using vvi = std::vector; vvi graph(N, vi(N)); for (int i{}; i < M; i++) { int a, b; int64_t c; scanf("%d%d%lld", &a, &b, &c); a--; b--; graph[a][b] = std::max(graph[a][b], c); graph[b][a] = std::max(graph[b][a], c); } vvi dp(1 << N, vi(N, -1)); for (int i{}; i < N; i++) dp[1 << i][i] = 0; int64_t max{}; for (int set_i{1}; set_i < (1 << N); set_i++) { for (int now_i{}; now_i < N; now_i++) { max = std::max(max, dp[set_i][now_i]); if ((~set_i >> now_i & 1) || dp[set_i][now_i] < 0) continue; for (int next_i{}; next_i < N; next_i++) if ((~set_i >> next_i & 1) && graph[now_i][next_i] > 0) dp[set_i | (1 << next_i)][next_i] = std::max(dp[set_i | (1 << next_i)][next_i], dp[set_i][now_i] + graph[now_i][next_i]); } } printf("%lld\n", max); return 0; }