#include using namespace std; #define FOR(i,s,t) for(int i = s; i < t; i++) using LL = long long; using VL = vector; int main() { int N, M; cin >> N >> M; const LL LINF = 1e18; vector cost(N, VL(N, -LINF)); FOR(i, 0, M) { LL a, b, c; cin >> a >> b >> c; a--, b--; cost[a][b] = cost[b][a] = max(cost[b][a], c); } vector dp(1 << N, VL(N, -LINF)); FOR(i, 0, N) { dp[1 << i][i] = 0; } LL ans = 0; FOR(state, 0, 1 << N) { FOR(i, 0, N) { if (state & 1 << i) { if (dp[state][i] == -LINF)continue; FOR(j, 0, N) { if (i == j)continue; if (state & 1 << j)continue; if (cost[i][j] ==- LINF)continue; int nx = state | (1 << j); dp[nx][j] = max(dp[nx][j], dp[state][i] + cost[i][j]); ans = max(ans, dp[nx][j]); } } } } cout << ans << endl; }