#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(ll i = m;i < n;i++) #define FORR(i, m, n) for(ll i = m;i >= n;i--) #define REPO(i, n) for(int i = 1;i <= n;i++) #define ll long long #define INF 1999999999 #define MINF -1999999999 #define INF64 1999999999999999999 #define ALL(n) n.begin(),n.end() #define MOD 1000000007 ll n, m, s[20][20], dp[100000]; int main() { cin >> n >> m; REP(i, m) { ll a, b, c; cin >> a >> b >> c; s[a][b] = c; } REP(i, 1 << n) { REP(j, n) { if (!(i & 1 << j)) { ll now = 0; REP(k, m) { if (!(i & 1 << k)) { now += s[j][k]; } } dp[i + (1 << j)] = max(dp[i + (1 << j)], dp[i] + now); } } } cout << dp[(1 << n) - 1] << endl; }