#include #include #include using namespace std; int main(){ int ans = 0,n,m; cin >> n >> m; vector arr(n); for(int i = 0;i < n;i++) arr[i] = i; vector > table(n,vector(n)); for(int i = 0;i < m;i++){ int i1,i2,score; cin >> i1 >> i2 >> score; table[i1][i2] += score; } do{ int tmp = 0; for(int i = 0;i < n;i++) for(int j = i + 1;j < n;j++) tmp += table[arr[i]][arr[j]]; ans = max(ans,tmp); }while(next_permutation(arr.begin(),arr.end())); cout << ans << endl; }