import sys from functools import lru_cache from itertools import permutations def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, M = map(int, input().split()) scores = {} for i in range(M): item1, item2, score = map(int, input().split()) scores[item1, item2] = score # debug(scores, locals()) max_score = -1 for line in permutations(range(N)): # debug(line, locals()) score = 0 for i in range(N): for j in range(i + 1, N): if (line[i], line[j]) in scores: score += scores[line[i], line[j]] max_score = max(max_score, score) print(max_score) if __name__ == '__main__': solve()