program nono;
type jl=record
left:integer;
right:integer;
cost:integer;
end;
var xx,xx2:longint;
ri,ro:text;
city:array [1..500] of boolean;
js:longint;
jg:real;
pan:boolean;
road:array[1..500] of jl;
n,m:integer;
procedure go;
var zx1,zx2:longint;
x1,x2:integer;
begin
zx1:=10000;
for x1:=1 to n do
if city[x1]=true then
for x2:=1 to m do
if (((road[x2].left=x1) and (city[road[x2].right]=false)) or
((road[x2].right=x1) and (city[road[x2].left]=false))) and (road[x2].cost<zx1) then
begin
zx1:=road[x2].cost;
zx2:=x2;
end;
city[road[zx2].left]:=true;
city[road[zx2].right]:=true;
js:=js+zx1;
go;
end;
begin
assign(ri,'road.in');
assign(ro,'road.out');
reset(ri);
rewrite(ro);
readln(ri,n,m);
for xx:=1 to n do city[xx]:=false;
for xx:=1 to m do
begin
readln(ri,road[xx].left,road[xx].right,road[xx].cost);
if xx<n-1 then writeln(ro,'0')
else
begin
city[road[1].left]:=true;
js:=0;
go;
pan:=true;
for xx2:=1 to n do
if city[xx2]=false then pan:=false;
if pan=false then writeln(ro,'0');
if pan=true then
begin
jg:=js/0.1;
writeln(ro,js div 2,'.',round(jg));
end;
end;
end;
close(ri);
close(ro);
end.