#include template T in() { abort(); return T(); } template<> std::string in() { std::string str; std::cin >> str; return str; } template<> int in() { int x; scanf("%d", &x); return x; } template void out(T x) { abort(); } template<> void out(const char* x) { printf("%s\n", x); } template<> void out(std::string x) { std::cout << x << std::endl; } template<> void out(int x) { printf("%d\n", x); } template<> void out(long x) { printf("%ld\n", x); } int score[10][10]; int n, m; int dfs(int i, int xs[10], bool check[10], int w) { if( i == n ) { return w; } int max = 0; for(int j = 0; j < n; ++j) { if( check[j] ) continue; int w2 = w; for(int k = 0; k < i; ++k) { w2 += score[xs[k]][j]; } xs[i] = j; check[j] = true; max = std::max(max, dfs(i + 1, xs, check, w2)); check[j] = false; xs[i] = -1; } return max; } int main() { n = in(); m = in(); for(int i = 0; i < m; ++i) { int a, b, c; a = in(); b = in(); c = in(); score[a][b] = c; } int xs[10] = {}; bool check[10] = {}; out( dfs(0, xs, check, 0) ); return 0; }