#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; int d[20][20]; int dp[1 << 16][20]; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; rep(i, 0, n) rep(j, 0, n) d[i][j] = -1; rep(i, 0, m){ int a, b, c; cin >> a >> b >> c; a--; b--; d[a][b] = max(d[a][b], c); d[b][a] = max(d[b][a], c); } rep(i, 0, 1 << n) rep(j, 0, n) dp[i][j] = -1; rep(i, 0, n) dp[1 << i][i] = 0; for(int mask = 0; mask < (1LL << n); mask++){ for(int i = 0; i < n; i++){ if(dp[mask][i] == -1) continue; for(int j = 0; j < n; j++){ if(mask & (1LL << j)) continue; if(d[i][j] == -1) continue; dp[mask | (1LL << j)][j] = max(dp[mask | (1LL << j)][j], dp[mask][i] + d[i][j]); } } } int ans = 0; rep(i, 0, 1 << n){ rep(j, 0, n){ ans = max(ans, dp[i][j]); } } cout << ans << endl; }