import itertools def main(): N, M = map(int,input().split()) max_score = 0 score = [] for i in range(M): score.append(list(map(int,input().split()))) data = list(itertools.permutations(range(N))) for tg in data: rt_score = check(tg, score) if max_score < rt_score: max_score = rt_score print(max_score) def check(tg ,score ): rt_score = 0 for sc in score: ind1 = tg.index(sc[0]) ind2 = tg.index(sc[1]) if not(ind1==-1) and ind1 < ind2: rt_score += sc[2] return rt_score if __name__ == "__main__": main()