n, m = map(int, input().split()) dist = [[None for _ in range(n)] for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a -= 1 b -= 1 if dist[a][b] is None: dist[a][b] = c dist[b][a] = c else: d = max(dist[a][b], c) dist[a][b] = d dist[b][a] = d dp = [[None for _ in range(n)] for _ in range(1 << n)] for v in range(n): dp[1 << v][v] = 0 ans = 0 for mask in range(1 << n): dpm = dp[mask] for cur in range(n): if dpm[cur] is None: continue for nxt in range(n): if (mask >> nxt) & 1 != 0 or dist[cur][nxt] is None: continue d = dpm[cur] + dist[cur][nxt] if dp[mask | (1 << nxt)][nxt] is None: dp[mask | (1 << nxt)][nxt] = d else: dp[mask | (1 << nxt)][nxt] = max(dp[mask | (1 << nxt)][nxt], d) ans = max(ans, d) print(ans)