dp = [-1] * (1 << 10) score = [0] * 1000 N, M = map(int, raw_input().split()) for t in xrange(M): a, b, c = map(int, raw_input().split()) score[a * N + b] = c def solve(m): if dp[m] != -1: return dp[m] res = 0 for i in xrange(0, N): if (m >> i) & 1 == 0: tmp = 0 for j in xrange(0, N): if (m >> j) & 1 == 1: tmp += score[i * N + j] res = max(res, tmp + solve(m | (1 << i))) dp[m] = res return res print solve(0)