N, M = map(int, input().split()) S = [[0]*N for _ in range(N)] for _ in range(M): i, j, s = map(int, input().split()) S[i][j] = s dp = [[0]*N for _ in range(2**N)] ans = [0]*2**N for bit in range(2**N): for i in range(N): if bit>>i & 1: continue res = 0 for j in range(N): if bit>>j & 1: res += S[j][i] dp[bit+2**i][i] = max(dp[bit+2**i][i], max(dp[bit])+res) print(max(dp[2**N-1]))