#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector> A(N, vector(N, 0)); rep(i,M) { int a,b,s; cin >> a >> b >> s; A[a][b] = s; } vector id(N); iota(id.begin(), id.end(), 0); int ans = 0; do { int cur = 0; rep(i,N)rep(j,i) cur += A[id[j]][id[i]]; ans = max(ans, cur); } while(next_permutation(id.begin(), id.end())); cout << ans << endl; }