#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll N, M; vector> g; vector> dp; ll dfs(ll S, ll pre) { if (S == (1 << N) - 1) return 0; if (pre != -1 && dp[S][pre] != -1) return dp[S][pre]; ll res = 0; if (pre == -1) { for (ll i = 0; i < N; i++) chmax(res, dfs(1 << i, i)); return res; } else { for (ll i = 0; i < N; i++) { if (!(S >> i & 1) && g[pre][i]) chmax(res, dfs(S + (1 << i), i) + g[pre][i]); } return dp[S][pre] = res; } } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%lld %lld", &N, &M); g = vector>(N, vector(N)); dp = vector>(1 << N, vector(N, -1)); for (ll i = 0; i < M; i++) { ll a, b, c; scanf("%lld %lld %lld", &a, &b, &c); a--; b--; chmax(g[a][b], c); chmax(g[b][a], c); } cout << dfs(0, -1) << endl; return 0; }