#include using namespace std; using ll = long long; int p[15][15]; int main(){ int n, m; cin >> n >> m; for(int i = 0; i < m; i++){ int a, b, score; cin >> a >> b >> score; p[a][b] = score; } vector v; for(int i = 0; i < n; i++) v.push_back(i); int ans = 0; do{ int now = 0; for(int i = 0; i < n-1; i++) now += p[v[i]][v[i+1]]; ans = max(ans, now); }while(next_permutation(v.begin(), v.end())); cout << ans << endl; return 0; }