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 X = 1 for i in range(N): X *= i + 1 mx = 0 for i in range(X): mst = [c for c in range(N)] cdt = [None] * N x = i for j in range(N): x, m = divmod(x, len(mst)) cdt[j] = mst.pop(m) 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)