#include #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vll; const ll INF = INT_MAX; const ll MOD = 1e9+7; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll N,M;cin>>N>>M; vector > G[20]; for(ll i=0;i>a>>b>>s; G[b].emplace_back(make_tuple(a,s)); } ll dp[1<<15]; for(ll S=0;S<1<>i)&1)){ ll tmp=0; for(auto v:G[i])if((S>>get<0>(v))&1){ tmp+=get<1>(v); } dp[S|(1<