#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n, m; cin >> n >> m; vector> s(m); for (auto&& [a, b, c] : s) cin >> a >> b >> c; vector p(n); iota(p.begin(), p.end(), 0); int ans = 0; do { int sum = 0; for (auto [a, b, c] : s) { if (p[a] < p[b]) sum += c; } ans = max(ans, sum); } while (next_permutation(p.begin(), p.end())); cout << ans << endl; return 0; }