#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pll; typedef vector vll; typedef vector> vvll; #define for1(i,n) for (ll i=0;i<(n);i++) #define for2(i,m,n) for (ll i=(m);i<(n);i++) #define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d)) #define DEBUG 0 #define INF 1e18 ll N,M; vector> to(16); ll dfs(ll sc, ll loc, ll arr) { if ((arr & (1LL << loc)) != 0) { return -INF; } arr |= (1LL << loc); ll ret = sc; for (auto t : to[loc]) { ret = max(ret, dfs(sc + t.second, t.first, arr)); } return ret; } void solve() { ll i; cin >> N >> M; for1(i,M) { ll a,b,c; cin >> a >> b >> c; --a; --b; to[a].push_back(make_pair(b,c)); to[b].push_back(make_pair(a,c)); } ll ans = 0; // 駅iから出発する for1(i,N) { ans = max(ans,dfs(0,i,0)); } cout << ans << endl; } int main() { do { solve(); } while (DEBUG); }