n,m=tuple(map(int,input().split())) way=[set() for i in range(n)] for i in range(m): inp=tuple(map(int,input().split())) way[inp[0]-1].add((inp[1]-1,inp[2])) way[inp[1]-1].add((inp[0]-1,inp[2])) def longest(fr,to,without): maxd=0 for i in way[fr]: if not (i[0] in without): d=i[1]+longest(i[0],to,without+[fr]) if d>maxd: maxd=d return maxd maxd=0 for i in range(n): for j in range(m): if i==j: continue d=longest(i,j,[]) if maxd