#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; int N, M, aai[14][14], dp[1 << 14]; int main(){ cin >> N >> M; rep(i, M){ int x, y, score; cin >> x >> y >> score; aai[x][y] = score; } rep(S, 1 << N){ rep(addItem, N)if((S>>addItem&1)==0){ int addPoint = 0; rep(preItem, N){ if(S >> preItem & 1){ addPoint += aai[preItem][addItem]; } } smax(dp[1 << addItem | S], dp[S] + addPoint); } } cout << dp[(1 << N) - 1] << endl; }