#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>m; vector x(m),y(m),z(m); for(Int i=0;i>x[i]>>y[i]>>z[i]; Int s=1< > sc(n,vector(s,0)); for(Int i=0;i>x[j])&1) sc[i][b]+=z[j]; } } } vector dp(s,0); for(Int b=0;b>i)&1) continue; chmax(dp[b|(1<