#!/usr/bin/python # -*- coding: utf-8 -*- # import from sys import stdin, setrecursionlimit setrecursionlimit(10**8) def int_map(): return map(int,input().split()) def int_list(): return list(map(int,input().split())) def int_mtx(N): x = [list(map(int, stdin.readline().split())) for _ in range(N)] return x def str_mtx(N): x = [list(stdin.readline()[:-1]) for _ in range(N)] return x def print_space(l): return print(" ".join([str(x) for x in l])) """ main code """ N,M = int_map() G = [[] for _ in range(N)] for _ in range(M): i,j,c = int_map() G[j].append([i,c]) dp = [0 for _ in range(2**N)] for s in range(2**N): for j in range(N): if s >> j & 1 == 0: cst = 0 for i,c in G[j]: if s >> i & 1 == 1: cst += c dp[s+2**j] = max(dp[s+2**j], dp[s]+cst) print(dp[2**N-1])