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(list(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]) if sc[1] in tg[ind1:]: rt_score += sc[2] return rt_score if __name__ == "__main__": main()