from collections import defaultdict n, m = map(int, input().split()) G = defaultdict(list) for _ in range(m): a, b, p = map(int, input().split()) G[a].append((b, p)) DP = [-1 for _ in range(1 << n)] DP[0] = 0 for bit in range(1 << n): for i in range(n): res = 0 if (bit >> i) & 1: continue for j, p in G[i]: if (bit >> j) & 1: res += p nbit = bit | (1 << i) DP[nbit] = max(DP[nbit], DP[bit] + res) print(DP[-1])