n, m = map(int, input().split()) from collections import defaultdict d = defaultdict(lambda: []) for i in range(m): a, b, c = map(int, input().split()) d[b].append((a, c)) INF = 10**18 dp = [-INF]*(1<>i)&1: continue ns = s|(1<>j)&1: x += c dp[ns] = max(dp[ns], dp[s]+x) print(dp[-1])