#include #include using namespace std; int main(void) { int p[9]; int s[9][9] = {0}; int n, m; cin >> n >> m; for(int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; s[a][b] = c; } for(int i = 0; i < n; i++) p[i] = i; int res = 0; do { int sum = 0; for(int i = 0; i < n; i++) { int ki = p[i]; for(int j = i + 1; j < n; j++) { int kj = p[j]; sum += s[ki][kj]; } } res = max(res, sum); }while(next_permutation(p, p + n)); cout << res << endl; return 0; }