#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; void solve() { int N, M, MI = INT_MIN / 3; cin >> N >> M; vector D(N, vi(N, MI)); rep(i, M) { int a, b, c; cin >> a >> b >> c; --a; --b; smax(D[a][b], c); smax(D[b][a], c); } vector dp(N, vi(1 << N, MI)); rep(i, N)dp[i][1 << i] = 0; int ans = MI; rep(S, 1 << N)rep(i, N) { rep(j, N)if (D[i][j] != MI && !(S >> j & 1)) { smax(dp[j][S | 1 << j], dp[i][S] + D[i][j]); } smax(ans, dp[i][S]); } cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }