N, M = map(int, input().split()) score = [[0] * N for _ in range(N)] for _ in range(M): x, y, z = map(int, input().split()) score[x][y] = z dp = [0] * (1 << N) for S in range(1 << N): for i in range(N): if S >> i & 1: continue cost = 0 for j in range(N): if S >> j & 1: cost += score[i][j] dp[S | 1 << i] = max(dp[S | 1 << i], dp[S] + cost) print(dp[-1])