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(n)] for _ in range(1 << n)] for i in range(n): DP[1 << i][i] = 0 for bit in range(1 << n): for i in range(n): if (bit >> i) & 1: if DP[bit][i] != -1: for j, p in G[i]: if (bit >> j) & 1 == 0: nbit = bit | (1 << j) DP[nbit][j] = max(DP[nbit][j], DP[bit][i] + p) ans = 0 for bit in range(1 << n): for i in range(n): if (bit >> i) & 1: ans = max(ans, DP[bit][i]) print(ans)