import java.util.*; public class Main { static int n; static int[][] score; static int[] dp; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); score = new int[n][n]; for (int i = 0; i < m; i++) { score[sc.nextInt()][sc.nextInt()] = sc.nextInt(); } dp = new int[1 << n]; Arrays.fill(dp, -1); dp[0] = 0; System.out.println(dfw((1 << n) - 1)); } static int dfw(int mask) { if (dp[mask] < 0) { for (int i = 0; i < n; i++) { if ((mask & (1 << i)) == 0) { continue; } int sum = 0; for (int j = 0; j < n; j++) { if (i == j || (mask & (1 << j)) == 0) { continue; } sum += score[j][i]; } dp[mask] = Math.max(dp[mask], dfw(mask ^ (1 << i)) + sum); } } return dp[mask]; } }