import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int[][] score = new int[n][n]; for(int i = 0; i < m; i++) { int i1 = sc.nextInt(); int i2 = sc.nextInt(); int s = sc.nextInt(); score[i2][i1] = s; } int p = (int)Math.pow(2, n); int[] dp = new int[p]; for(int i = 1; i < p; i++) { for(int j = 0; j < n; j++) { if((i & (1 << j)) != 0) { int i1 = i - (1 << j); int t = dp[i1]; for(int k = 0; k < n; k++) { if((i1 & (1 << k)) != 0) { t += score[j][k]; } } dp[i] = Math.max(dp[i], t); } } } System.out.println(dp[p - 1]); } }