#include using namespace std; #define LOG(...) fprintf(stderr,__VA_ARGS__) //#define LOG(...) #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define REP(i,n) for(int i=0;i<(int)(n);++i) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) typedef long long ll; typedef unsigned long long ull; typedef vector vb; typedef vector vi; typedef vector vll; typedef vector vvb; typedef vector vvi; typedef vector vvll; typedef pair pii; typedef pair pll; struct Item { int n, score; }; int main() { int n, m; cin >> n >> m; vvi score(10, vi(10, 0)); REP(i, m) { int a, b, c; cin >> a >> b >> c; score[a][b] = c; } vi ns(n); REP(i, n) ns[i] = i; int ma = 0; do { int s = 0; REP(i, n-1) { FOR(j, i+1, n) { s += score[ns[i]][ns[j]]; } } ma = max(ma, s); } while (next_permutation(ALL(ns))); cout << ma << endl; }