n, m = map(int, input().split()) score = [[0] * n for i in range(n)] for i in range(m): a, b, c = map(int, input().split()) score[a][b] = c comb = (1 << n) - 1 dp = [0] * (comb + 1) for c in range(1, comb): for i in range(n): f1 = 1 << i if not c & f1 == 0: continue cf = c | f1 s = dp[c] for j in range(n): f2 = 1 << j if c & f2 == 0: continue s += score[j][i] dp[cf] = max(s, dp[cf]) print(dp[-1])