def maxProfit(board,dp,_st): st=_st maxP=0 i=0 while True: bonus=0 if st & 2**i != 0 and i in board: for k,s in board[i].items(): if st & 2**k != 0: bonus += s maxP = max(maxP, dp[st-2**i]+bonus) i+=1 if st<2**i: break return maxP N,M=map(int,raw_input().split()) board={} for _ in xrange(M): i1,i2,s=map(int,raw_input().split()) if i2 not in board: board[i2]={} board[i2][i1]=s dp=[0]*(2**N) for i in xrange(1,2**N): dp[i]=maxProfit(board,dp,i) print dp[2**N-1]