from collections import defaultdict N, M = map(int, input().split()) G = defaultdict(dict) for _ in range(M): u, v, score = map(int, input().split()) G[v][u] = score dp = [0] * (1 << N) for bit in range(1 << N): for u in range(N): if bit >> u & 1: continue tot = 0 for v in range(N): if ~bit >> v & 1: continue if v in G[u]: tot += G[u][v] dp[bit | (1 << u)] = max(dp[bit | (1 << u)], dp[bit] + tot) print(dp[-1])