#include using namespace std; int main() { int N, M; scanf("%d %d", &N, &M); vector< vector > table(N, vector(N)); for (int i = 0; i < M; ++i) { int a, b, c; scanf("%d %d %d", &a, &b, &c); table[a][b] = c; } vector items(N); iota(items.begin(), items.end(), 0); int ans = -1; do { int tmp = 0; for (int i = 1; i < N; ++i) { tmp += table[items[i]][items[i - 1]]; } ans = max(tmp, ans); } while(next_permutation(items.begin(), items.end())); printf("%d\n", ans); return 0; }