import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = br.readLine().split(" "); int n = Integer.parseInt(str[0]); int m = Integer.parseInt(str[1]); int score[][] = new int[n][n]; for (int i = 0; i < m; i++) { str = br.readLine().split(" "); int a = Integer.parseInt(str[0]); int b = Integer.parseInt(str[1]); int s = Integer.parseInt(str[2]); score[a][b] = s; } int dp[] = new int[(1 << n)]; dp[0] = 0; for (int bit = 0; bit < (1 << n); bit++) { for (int i = 0; i < n; i++) { if ((bit & (1 << i)) != 0) continue; int cost = 0; for (int j = 0; j < n; j++) { if ((bit & (1 << j)) != 0) continue; cost += score[j][i]; } int now = ((bit | (1 << i))); dp[now] = Math.max(dp[now], dp[bit] + cost); } } System.out.println(dp[(1 << n) - 1]); } }