#include using namespace std; int main() { int n, m; cin >> n >> m; vector> g(n, vector(n)); for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; g[a][b] = c; } int ans = 0; vector p(n); iota(p.begin(), p.end(), 0); do { int score = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { score += g[p[i]][p[j]]; } } ans = max(ans, score); } while (next_permutation(p.begin(), p.end())); cout << ans << endl; }