#include using namespace std; int main() { int n, m; cin >> n >> m; vector item1(m), item2(m), score(m); for (int i = 0;i < m;i++) { cin >> item1[i] >> item2[i] >> score[i]; } vector v(n); iota(v.begin(), v.end(), 0); int sum_max = 0; do { int sum = 0; for (int i = 0;i < m;i++) { if (v[item1[i]] < v[item2[i]]) { sum += score[i]; } } sum_max = max(sum_max, sum); } while (next_permutation(v.begin(), v.end())); cout << sum_max << endl; return 0; }