#include using namespace std; #define vi vector #define vvi vector #define vs vector #define pb push_back #define P pair #define vp vector

#define PP pair #define vpp vector #define fi first #define se second #define INF (1<<30) #define MOD 1000000007 #define REP(i,n) for(int i=0;i=0;i--) #define FOR(i,m,n) for(int i=m;i>n>>m; vvi d(n,vi(n)); REP(i,m){ int a,b,c; cin>>a>>b>>c; d[b][a]=c; } vi vec; REP(i,n)vec.pb(i); int ans=0; do{ int sum=0; REP(i,n){ REP(j,i){ sum+=d[j][i]; } } ans=max(ans,sum); }while(next_permutation(all(vec))); cout<