program djsb;
var
x,y,z,n,m,i:longint;
b:array[1..200,0..200]of longint;
a:array[1..200,1..200]of longint;
dist:array[1..200,1..200]of longint;
t:array[1..30000]of integer;
procedure init;
begin
assign(input,'djsb.in');
reset(input);
assign(output,'djsb.out');
rewrite(output);
readln(n,m);
fillchar(b,sizeof(b),0);
fillchar(a,sizeof(a),0);
for i:=1 to m do
begin
readln(x,y,z);
inc(x);
inc(y);
inc(b[x,0]);
b[x,b[x,0]]:=y;
inc(b[y,0]);
b[y,b[y,0]]:=x;
a[x,y]:=z;
a[y,x]:=z;
end;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure spfa(st:integer);
var
now,i,head,tail:integer;
v:array[1..100]of boolean;
begin
head:=0;
tail:=1;
fillchar(v,sizeof(v),false);
fillchar(t,sizeof(t),0);
t[1]:=st;
for i:=1 to n do dist[st,i]:=maxint;
dist[st,st]:=0;
var
x,y,z,n,m,i:longint;
b:array[1..200,0..200]of longint;
a:array[1..200,1..200]of longint;
dist:array[1..200,1..200]of longint;
t:array[1..30000]of integer;
procedure init;
begin
assign(input,'djsb.in');
reset(input);
assign(output,'djsb.out');
rewrite(output);
readln(n,m);
fillchar(b,sizeof(b),0);
fillchar(a,sizeof(a),0);
for i:=1 to m do
begin
readln(x,y,z);
inc(x);
inc(y);
inc(b[x,0]);
b[x,b[x,0]]:=y;
inc(b[y,0]);
b[y,b[y,0]]:=x;
a[x,y]:=z;
a[y,x]:=z;
end;
end;
procedure closef;
begin
close(input);
close(output);
end;
procedure spfa(st:integer);
var
now,i,head,tail:integer;
v:array[1..100]of boolean;
begin
head:=0;
tail:=1;
fillchar(v,sizeof(v),false);
fillchar(t,sizeof(t),0);
t[1]:=st;
for i:=1 to n do dist[st,i]:=maxint;
dist[st,st]:=0;