#include using namespace std; //#define int long long #define INF 1e9 #define LINF 1e18 const int MOD = 1e9 + 7; const int dy[]={0, 0, 1, -1}; const int dx[]={1, -1, 0, 0}; typedef pair P; typedef pair Pi; typedef pair PP; template void chmin(T& a, const T& b) { a = min(a, b); } template void chmax(T& a, const T& b) { a = max(a, b); } int N, M; int score[20][20]; int dp[1 << 14]; signed main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for(int i = 0; i < M; ++i) { int item1, item2, s; cin >> item1 >> item2 >> s; score[item1][item2] = s; } for(int mask = 0; mask < (1 << 14); ++mask) { for(int i = 0; i < N; ++i) { if(mask & (1 << i)) continue; int add = 0; for(int j = 0; j < N; ++j) { if(mask & (1 << j)) add += score[i][j]; chmax(dp[mask | (1 << i)], dp[mask] + add); } } } cout << dp[(1 << N) - 1] << endl; return 0; }