def max(a,b); a > b ? a : b; end N, M = gets.split.map(&:to_i) S = Array.new(N){ Array.new(N, 0) } M.times do t1, t2, score = gets.split.map(&:to_i) S[t1][t2] = score end dp = Array.new(1 << N, 0) (1 << N).times do |s| used = N.times.select{|i| s[i] > 0 } used.each do |i| up = used.map{|j| S[j][i] }.sum dp[s] = max(dp[s],dp[s ^ (1 << i)] + up) end end puts dp[-1]