N, M = map(int, input().split()) g = [[-1]*N for _ in range(N)] for i in range(M): a, b, c = map(int, input().split()) a -= 1 b -= 1 g[a][b] = max(g[a][b], c) g[b][a] = max(g[b][a], c) ans = 0 # 集合 i は訪問済みで最後に訪れたのが j の最大値 dp = [[-1]*N for _ in range(1 << N)] for i in range(N): dp[1 << i][i] = 0 ans = 0 for i in range(1 << N): for j in range(N): if not (i >> j) & 1: continue if dp[i][j] == -1: continue for k in range(N): if (i >> k) & 1: continue if g[j][k] == -1: continue dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k], dp[i][j] + g[j][k]) ans = max(ans, dp[i | (1 << k)][k]) # print(*dp, sep="\n") print(ans)