n,m=io.read("*n","*n") p= {} e={} l={} for i = 1,n do p[i]=i e[i]={} l[i]=-1 end l[1]=0 function F(i) j=i while p[i]~=i do i=p[i] end while p[j]~=i do p[j],j=i,p[j] end return i end q={} for i=1,m do q[i]={io.read("*n","*n","*n")} end table.sort(q,function(a,b) return a[3]>b[3] end) w=0 for i=1,m do a=q[i][1] b=q[i][2] c=q[i][3] if c