#include using namespace std; int main() { int N, M, it1[100], it2[100], scr[100]; cin >> N >> M; for (int i = 0; i < M; i++) { cin >> it1[i] >> it2[i] >> scr[i]; } vector V(N); for (int i = 0; i < N; i++) { V[i] = i; } int ans = 0; do { int score = 0; for (int i = 0; i < M; i++) { if (V[it1[i]] < V[it2[i]]) score += scr[i]; } ans = max(ans, score); } while (next_permutation(V.begin(), V.end())); cout << ans << endl; }