N, M = map(int, input().split()) A = [[0] * N for _ in range(N)] for _ in range(M): u, v, score = map(int, input().split()) A[u][v] = score dp = [0] * (1 << N) for S in range(1 << N): for u in range(N): if S & (1 << u): continue # uを加えたときのscoreを計算 score = 0 for v in range(N): if not (S & (1 << v)): continue score += A[v][u] dp[S ^ (1 << u)] = max(dp[S ^ (1 << u)], dp[S] + score) print(dp[-1])