import std.stdio, std.conv, std.math, std.string, std.range, std.array, std.algorithm; void main(){ auto buf = readln().strip().split().map!(to!int)(); immutable N = buf[0]; immutable M = buf[1]; int[10][10] map; foreach(immutable int i; 0 .. M) { auto buf2 = readln().strip().split().map!(to!int)(); map[buf2[0]][buf2[1]] = buf2[2]; } int[] a = iota(0, N).array(); int ans; do { int t; foreach(immutable int i; 0 .. N) { foreach(immutable int j; i+1 .. N) { t += map[a[i]][a[j]]; } } ans = max(ans, t); } while (nextPermutation(a)); writeln(ans); }