#include #define FOR(i, n, m) for(long long i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = std::int_fast64_t; using ld = long double; using P = pair; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-15; template ostream& operator<<(ostream& os, pair p) { os << to_string(p.first) << " " << to_string(p.second); return os; } template ostream& operator<<(ostream& os, vector& v) { REP(i, v.size()) { if(i) os << " "; os << to_string(v[i]); } return os; } /* template struct Treap { double drand() { // random number in [0, 1] static random_device rd; static mt19937 mt(rd()); return (unsigned)mt() / (double)numeric_limits::max(); } T v; double p; int cnt; Treap* lch; Treap* rch; Treap(T v) : v(v), p(drand()), cnt(1), lch(NULL), rch(NULL) { } Treap* update() { this->size = size(this->lch) + size(this->rch) + 1; return this; } static int size(Treap* t) { if(!t) return 0; else return t->cnt; } static Treap* merge(Treap* l, Treap* r) { if(!l || !r) { if(!l) return r; else return l; } if(l->p >= r->p) { l->rch = merge(l->rch, r); return l->update(); } else { r->lch = merge(r->lch, l); return r->update(); } } static pair split(Treap* t, int k) { // split [0, k) and [k, n) if(k == 0) return {NULL, t}; if(!(t->l)) { auto tmp = split(t->r, k - 1); t->r = tmp.first; return {t->update(), tmp.second}; } else if(!(t->r)) { auto tmp = split(t->r, k - 1); t->r = tmp.first; return {t->update(), tmp.second}; } else { } } Treap* insert() { } Treap* erase() { } T operator[](int k) { } }; */ int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector> g(n, vector(n, -1)); REP(i, m) { int a, b, c; cin >> a >> b >> c; a--; b--; g[a][b] = max(g[a][b], c); g[b][a] = max(g[b][a], c); } vector> dp((1 << n), vector(n, -1)); REP(i, n) { dp[1 << i][i] = 0; } ll ans = 0; REP(bit, 1 << n) REP(j, n) { bitset<16> bi(bit); if(bi.count() <= 1) continue; if(!bi[j]) continue; bi[j] = 0; REP(k, n) { if(!bi[k]) continue; if(g[k][j] == -1) continue; if(dp[bi.to_ullong()][k] != -1) dp[bit][j] = max(dp[bit][j], dp[bi.to_ullong()][k] + g[k][j]); } ans = max(ans, dp[bit][j]); } cout << ans << endl; return 0; } // ---------------------------------------