#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) template inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); } template inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); } typedef long long ll; int const inf = 1<<29; int G[14][14]; int main() { int N, M; cin >> N >> M; rep(i, M) { int i1, i2, c; cin >> i1 >> i2 >> c; G[i1][i2] = c; } static int dp[1<<14]; rep(S, 1<> i & 1)) { int sum = 0; rep(j, N) { if(S >> j) { sum += G[j][i]; } } maximize(dp[S|(1<