N, M = map(int, input().split()) master = [[0] * N for _ in range(N)] for _ in range(M): i1, i2, score = map(int, input().split()) master[i1][i2] = score dp = [0] * (1 << N) for S in range(1, 1 << N): for u in range(N): if not (S & (1 << u)): continue score = 0 for v in range(N): if S & (1 << v): score += master[u][v] dp[S] = max(dp[S], dp[S ^ (1 << u)] + score) print(dp[-1])