#include #include #include using namespace std; struct nya{ int pv,nx,scr; }; int main(){ int n,m;cin>>n>>m; vector A(n); for(int i = 0; n > i; i++){ A[i] = i; } vector Z(m); for(int i = 0; m > i; i++){ cin>>Z[i].pv>>Z[i].nx>>Z[i].scr; } int ans = 0; do{ int tmp = 0; for(int i = 0; m > i; i++){ for(int j = 0; n > j; j++){ if(A[j] == Z[i].pv){ tmp += Z[i].scr; break; } if(A[j] == Z[i].nx){ break; } } } ans = max(ans,tmp); }while(next_permutation(A.begin(),A.end())); cout << ans << endl; }