#include #include #include #include #include void solve() { int n, m; std::cin >> n >> m; std::vector> ts(m); for (auto& t : ts) { int x, y, c; std::cin >> x >> y >> c; t = std::make_tuple(x, y, c); } std::vector idxs(n); std::iota(idxs.begin(), idxs.end(), 0); int ans = 0; do { int score = 0; for (auto t : ts) { int x, y, c; std::tie(x, y, c) = t; if (idxs[x] < idxs[y]) score += c; } ans = std::max(ans, score); } while (std::next_permutation(idxs.begin(), idxs.end())); std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }