#include #include #include #include #include #include #include #include //#include #include using namespace std; typedef long long ll; #define rep(i,b) for(ll i=0;i<(b);++i) #define rep1(i,b) for(ll i=1;i<=(b);++i) #define vec vector #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl; int N, M; int item1[80]; int item2[80]; int score[80]; int main() { cin >> N >> M; rep(i, M) { cin >> item1[i] >> item2[i] >> score[i]; } vector v(N); iota(v.begin(), v.end(), 0); int maxval = 0; int dp[11]; // 数字からindex do { int points = 0; rep(i, N) { dp[v[i]] = i; } rep(i, M) { if (dp[item1[i]] < dp[item2[i]]) points += score[i]; } maxval = max({maxval, points}); // for (auto x: v) cout << x << " "; cout << "\n"; } while ( next_permutation(v.begin(), v.end())); cout << maxval << endl; }