#include #include using namespace std; int N; int M; int d[1 << 14]; int item1, item2, sc; int score[14][14] = { 0 }; int main() { cin >> N >> M; for (int i = 0; i < M; i++) { cin >> item1 >> item2 >> sc; score[item1][item2] = sc; } for (int i = 0; i < 1 << N; i++) { d[i] = 0; } for (int i = 0; i < 1 << N; i++) { for (int j = 0; j < N; j++) { if (i != (i | (1 << j))) { int score_sum = 0; for (int k = 0; k < N; k++) { if (i == (i | (1 << k))) { score_sum += score[k][j]; } } d[i | 1 << j] = max(d[i | 1 << j], d[i] + score_sum); } } } cout << d[(1 << N) - 1] << endl; return 0; }