N, M = map(int, input().split()) UV = [list(map(int, input().split())) for _ in range(M)] P = [[0] * N for _ in range(N)] BC = [[] for _ in range(N + 1)] for i in range(1 << N): BC[i.bit_count()].append(i) for u, v, c in UV: P[u][v] = max(P[u][v], c) dp = [0] * (1 << N) for i in range(N): for j in BC[i]: for k in range(N): if j & (1 << k): continue j2 = j | (1 << k) tmp = 0 for x in range(N): if j & (1 << x): tmp += P[x][k] dp[j2] = max(dp[j2], dp[j] + tmp) print(dp[-1])