n, m = map(int, input().split()) info = [list(map(int, input().split())) for i in range(m)] p = [[0]*n for i in range(n)] for i in range(m): a, b, cost = info[i] p[a][b] = cost dp = [0]*(1 << n) for bit_state in range(1 << n): for i in range(n): if (bit_state >> i) & 1: continue score = 0 for j in range(n): if (bit_state >> j) & 1: score += p[j][i] dp[bit_state|(1 << i)] = max(dp[bit_state|(1 << i)], dp[bit_state] + score) print(dp[-1])