#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair const int inf = 1000000001; const ll INF = 1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<> n >> m; vii hyou(n, vi(n)); for (i = 0; i < m; i++) { int i1, i2, s; cin >> i1 >> i2 >> s; hyou[i1][i2] = s; } vi jun(n); for (i = 0; i < n; i++) { jun[i] = i; } int ans = -1; do { int temp = 0; for (i = 0; i < n; i++) { for (j = i+1; j < n; j++) { temp += hyou[jun[i]][jun[j]]; } } ans = max(ans, temp); }while(next_permutation(jun.begin(), jun.end())); cout << ans << endl; } /* 4 9 0 1 1 0 2 2 0 3 3 1 2 4 1 3 5 2 3 6 3 2 100 2 1 100 1 0 100 */