import itertools N, M = map(int, input().split()) tab = [[0] * N for _ in range(N)] for _ in range(M): i1, i2, s = map(int, input().split()) tab[i1][i2] = s mx = 0 for cdt in itertools.permutations([c for c in range(N)]): sm = 0 for j in range(N - 1): for k in range(j + 1, N): sm += tab[cdt[j]][cdt[k]] if sm > mx: mx = sm print(mx)