#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(ll i = 0;i < n;i++) #define REPR(i, n) for(ll i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(ll i = 1;i <= n;i++) #define ll long long #define INF (ll)1 << 60 #define MINF (-1 * INF) #define ALL(n) n.begin(),n.end() #define MOD (ll)1000000007 #define P pair ll n, m, ans, dp[210000][20], s[20][20]; int main() { REP(i, 210000) REP(j, 20)dp[i][j] = MINF; REP(i, 17)REP(j, 20)dp[(ll)pow(2, i)][j] = 0; cin >> n >> m; REP(i, m) { ll a, b, c; cin >> a >> b >> c; a--; b--; s[a][b] = c; s[b][a] = c; } REPO(i, (1ll << n) - 1) { REP(j, n) { if(!(i & (1ll << j))) continue; REP(k, n) { if (i & (1ll << k)) continue; if (s[j][k] == 0)continue; dp[i + (1ll << k)][k] = max(dp[i + (1ll << k)][k], dp[i][j] + s[j][k]); } } } REP(i, 210000) REP(j, 20) ans = max(ans, dp[i][j]); cout << ans << endl; }