#include #include #include #include using namespace std; int main() { int N, M; cin >> N >> M; vector> v(N, vector(N, 0)); for (int i = 0; i < M; ++i) { int a, b, c; cin >> a >> b >> c; v[a][b] = c; } vector item(N); iota(item.begin(), item.end(), 0); int res = 0; do { int tmp = 0; for (int i = 0; i < N; ++i) { for (int j = i + 1; j < N; ++j) { tmp += v[item[i]][item[j]]; } } res = max(res, tmp); } while (next_permutation(item.begin(), item.end())); cout << res << endl; }