#include using namespace std; typedef long long ll; #define REP(i,n) for(int (i)=0;(i)<(n);++(i)) #define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i)) #define EACH(e,v) for(auto& e:v) #define ALL(v) (v).begin(),(v).end() #define SORT(v) sort(ALL(v)) #define RSORT(v) sort((v).rbegin(),(v).rend()) #define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v))) #define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end()) template inline bool chmax(A &a,const B &b){if(a inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;} const int MOD = (int)1e9 + 7; const int INF = 1 << 30; const ll INFF = 1LL << 62; // 下にy, 右にx enum {R, U, L, D}; const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; int N, M; int graph[20][20]; ll dp[1 << 20][20]; signed main() { cin >> N >> M; REP(i, 20) REP(j, 20) graph[i][j] = -1; REP(i, 1 << 20) REP(j, 20) dp[i][j] = -INF; REP(i, 20) dp[1 << i][i] = 0; REP(i, M) { int A, B, C; cin >> A >> B >> C; --A, --B; chmax(graph[A][B], C); chmax(graph[B][A], C); } REP(mask, 1 << N) REP(nxt, N) { if (mask & (1 << nxt)) continue; int nxt_mask = mask | (1 << nxt); REP(cur, N) { if (dp[mask][cur] == -INF) continue; if (graph[cur][nxt] == -1) continue; chmax(dp[nxt_mask][nxt], dp[mask][cur] + graph[cur][nxt]); } } ll res = 0; REP(i, 1 << N) REP(j, N) chmax(res, dp[i][j]); cout << res << endl; // REP(i, 1 << N) REP(j, N) cout << (dp[i][j] == -INF ? -1 : dp[i][j]) << " \n"[j == N - 1]; }