import itertools def main(): N, M = map(int, input().split()) gen = (map(int, input().split()) for _ in range(M)) x = {str(k1) + str(k2): v for k1, k2, v in gen} score = 0 for i in itertools.permutations(range(N)): lineup = ''.join(map(str, i)) score_ = 0 for k, v in x.items(): if k in lineup: score_ += v score = max(score, score_) print(score) main()