#include "bits/stdc++.h" #define REP(i,n,N) for(int i=(n); i<(N); i++) #define RREP(i,n,N) for(int i=(N-1); i>=n; i--) #define CK(n,a,b) (a)<=(n)&&(n)<(b) #define p(s) cout<<(s)<>N>>M){ int ans=0; int score[100][100] = {}; REP(i,0,M){ int a,b,c; cin>>a>>b>>c; score[a][b]=c; } vector vt; REP(i,0,N){ vt.push_back(i); } do{ int mx=0; REP(i,0,N){ REP(j,i+1,N){ mx+=score[vt[i]][vt[j]]; } } ans=max(ans,mx); }while(next_permutation(vt.begin(), vt.end())); p(ans); } }