#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (INT_MAX/3) #define PI (2*acos(0.0)) #define EPS (1e-8) typedef long long ll; typedef unsigned long long ull; int N, M, item1[73], item2[73], score[73], I[9]; int main(){ ios_base::sync_with_stdio(0); cin >> N >> M; for(int i = 0; i < N; i++) I[i] = i; for(int i = 0; i < M; i++){ cin >> item1[i] >> item2[i] >> score[i]; } int _max = 0; do{ int sum = 0; for(int i = 0; i < M; i++){ bool al = false; for(int j = 0; j < N; j++){ if(item1[i] == I[j]) al = true; if(item2[i] == I[j] && al) sum += score[i]; } } _max = max(_max, sum); }while(next_permutation(I, I + N)); cout << _max << endl; return 0; }