from collections import defaultdict from itertools import combinations def solve(N, M, items2score): dp = [-float("inf")] * (1 << N) dp[0] = 0 for V in range(1 << N): for i in range(N): for j in range(N): if i == j: continue if not ((V >> i) & 1) or not ((V >> j) & 1): VV = V | (1 << i) | (1 << j) dp[VV] = max(dp[VV], dp[V] + items2score[(i, j)]) return dp[-1] def main(): N, M = map(int, input().split()) items2socre = defaultdict(int) for _ in range(M): i, j, s = map(int, input().split()) items2socre[(i, j)] = s ans = solve(N, M, items2socre) print(ans) if __name__ == "__main__": main()