var i,j,k,l,m,n,p,q,r,s,t,v,a1,a2,a3,a4,a5,ans,krus:longint;
road:array[0..300,0..300] of longint;
lab:array[0..300,0..300] of longint;
path:array[0..10000,1..3] of longint;
can:array[0..10000,0..50] of boolean;
f:array[0..50] of longint;
mid:array[1..3] of longint;
use:array[0..10000] of boolean;
root:array[0..300] of longint;
pd:boolean=true;
procedure qsort(x,y:longint);
var g,t,l,r:longint;
begin
l:=x;r:=y;
g:=path[(x+y) div 2,3];
repeat
while (path[l,3]<g) do inc(l);
while (path[r,3]>g) do dec(r);
if l<=r then
begin
mid:=path[l];path[l]:=path[r];path[r]:=mid;
inc(l);dec(r);
end;
until l>r;
if x<r then qsort(x,r);
if l<y then qsort(l,y);
end;
function ff(x:longint):longint;
begin
if root[x]=x then exit(x);
root[x]:=ff(root[x]);
ff:=root[x];
end;
procedure kruscal;
var g,t,l,r:longint;
begin
for g:=1 to p do if use[g] then
if ff(path[g,1])<>ff(path[g,2]) then
begin
krus:=krus+path[g,3];
root[root[path[g,1]]]:=root[path[g,2]];
end;
end;
begin
assign(input,'sango.in');
reset(input);
assign(output,'sango.out');
rewrite(output);
read(n,m,t,v,k);
fillchar(road,sizeof(road),255);
for i:=1 to m do
begin
read(l,r,s);
road[l,r]:=s;
road[r,l]:=s;
end;
p:=0;
for i:=1 to n-1 do
for j:=i+1 to n do
if road[i,j]>-1 then
begin
inc(p);
path[p,1]:=i;path[p,2]:=j;
path[p,3]:=road[i,j];
road:array[0..300,0..300] of longint;
lab:array[0..300,0..300] of longint;
path:array[0..10000,1..3] of longint;
can:array[0..10000,0..50] of boolean;
f:array[0..50] of longint;
mid:array[1..3] of longint;
use:array[0..10000] of boolean;
root:array[0..300] of longint;
pd:boolean=true;
procedure qsort(x,y:longint);
var g,t,l,r:longint;
begin
l:=x;r:=y;
g:=path[(x+y) div 2,3];
repeat
while (path[l,3]<g) do inc(l);
while (path[r,3]>g) do dec(r);
if l<=r then
begin
mid:=path[l];path[l]:=path[r];path[r]:=mid;
inc(l);dec(r);
end;
until l>r;
if x<r then qsort(x,r);
if l<y then qsort(l,y);
end;
function ff(x:longint):longint;
begin
if root[x]=x then exit(x);
root[x]:=ff(root[x]);
ff:=root[x];
end;
procedure kruscal;
var g,t,l,r:longint;
begin
for g:=1 to p do if use[g] then
if ff(path[g,1])<>ff(path[g,2]) then
begin
krus:=krus+path[g,3];
root[root[path[g,1]]]:=root[path[g,2]];
end;
end;
begin
assign(input,'sango.in');
reset(input);
assign(output,'sango.out');
rewrite(output);
read(n,m,t,v,k);
fillchar(road,sizeof(road),255);
for i:=1 to m do
begin
read(l,r,s);
road[l,r]:=s;
road[r,l]:=s;
end;
p:=0;
for i:=1 to n-1 do
for j:=i+1 to n do
if road[i,j]>-1 then
begin
inc(p);
path[p,1]:=i;path[p,2]:=j;
path[p,3]:=road[i,j];