#include #include using namespace std; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } int main() { int N, M; cin >> N >> M; vector D(N * N); REP(_, M) { int A, B, C; cin >> A >> B >> C; A--; B--; mmax(D[A * N + B], C); mmax(D[B * N + A], C); } vector> dp(N, vector(1 << N, -1)); REP(i, N) dp[i][1 << i] = 0; int ret = 0; REP(S, 1 << N) REP(d, N) if (((1 << d) & S) and dp[d][S] >= 0) { REP(dd, N) if (!((1 << dd) & S) and D[d * N + dd]) { mmax(dp[dd][S ^ (1 << dd)], dp[d][S] + D[d * N + dd]); mmax(ret, dp[dd][S ^ (1 << dd)]); } } cout << ret << endl; }