import java.util.*; public class Main { static int n; static int[][] scores; static int max = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); int m = sc.nextInt(); scores = new int[n][n]; for (int i = 0; i < m; i++) { scores[sc.nextInt()][sc.nextInt()] = sc.nextInt(); } check(0, 0, new HashSet<>()); System.out.println(max); } static void check(int idx, int total, HashSet used) { if (idx == n) { max = Math.max(max, total); return; } for (int i = 0; i < n; i++) { if (used.contains(i)) { continue; } int tmp = 0; for (int x : used) { tmp += scores[x][i]; } used.add(i); check(idx + 1, total + tmp, used); used.remove(i); } } }