#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define mp make_pair #define Fi first #define Se second #define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n'; using ll = long long int; using P = pair; using vi = vector; using vvi = vector; using vvvi = vector; using pii = pair; template using PQ = priority_queue; template using minPQ = priority_queue, greater>; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n >> m; vector score(n, vector

()); REP(i,m){ int u, v, s; cin >> u >> v >> s; score[u].emplace_back(P(v,s)); } int S = 1<> v) & 1)ret += w; } return ret; }; REP(s, S){ if(dp[s]==-1)continue; REP(i, n){ if( (~s >> i) & 1){ chmax(dp[s | (1<