n, m = map(int, input().split()) info = [list(map(int, input().split())) for i in range(m)] graph = [[0]*n for i in range(n)] for tmp1, tmp2, cost in info: tmp1 -= 1 tmp2 -= 1 graph[tmp1][tmp2] = max(graph[tmp1][tmp2], cost) graph[tmp2][tmp1] = max(graph[tmp2][tmp1], cost) # dp[subset][j] := すでにsubsetの集合を訪れていて、最後に訪問したのがjのときの最大値 dp = [[0]*n for i in range(2**n)] for subset in range(2**n): for j in range(n): if subset & 2**j != 0: for k in range(n): if subset & 2**k !=0 and graph[k][j] != 0: # subsetにjとkを含んでいて、kとjは連結である dp[subset][j] = max(dp[subset][j], dp[subset - 2**j][k] + graph[k][j]) ans = 0 for num in dp: ans = max(num + [ans]) print(ans)