program amenzi;
type lista=^celula;
celula=record
info:longint;
timp:longint;
next:lista;
end;
var n,m,k,p,i,x,y,z,j,h:longint;
d:array [1..150] of lista;
a,b:array [1..150,0..3500] of int64;
r:lista;
bufin,bufout:array[1..100000] of char;
begin
assign(input,'amenzi.in');
reset(input);
settextbuf(input,bufin);
assign(output,'amenzi.out');
rewrite(output);
settextbuf(output,bufout);
readln(n,m,k,p);
for i:=1 to m do
begin
readln(x,y,z);
new(r);
r^.info:=y;
r^.timp:=z;
r^.next:=d[x];
d[x]:=r;
new(r);
r^.info:=x;
r^.timp:=z;
r^.next:=d[y];
d[y]:=r;
end;
for i:=1 to n do
begin
new(r);
r^.info:=i;
r^.timp:=1;
r^.next:=d[i];
d[i]:=r;
end;
for i:=1 to k do
begin
readln(x,y,z);
b[x,y]:=b[x,y]+z;
end;
for i:=0 to 3500 do
for j:=1 to n do a[j,i]:=-1;
a[1,0]:=0;
for i:=1 to 3500 do
begin
for j:=1 to n do
begin
r:=d[j];
while (r<>nil) do
begin
if i-r^.timp>=0 then
if a[r^.info,i-r^.timp]<>-1 then
if a[r^.info,i-r^.timp] >=a[j,i] then a[j,i]:= a[r^.info,i-r^.timp];
r:=r^.next;
end;
{ for h:=1 to n do
begin
if d[j,h]>0 then
if (i-d[j,h]>=0)then
if (a[h,i-d[j,h]]<>-1) then
if a[h,i-d[j,h]]>=a[j,i] then a[j,i]:=a[h,i-d[j,h]];
end;}
if a[j,i]<>-1 then a[j,i]:=a[j,i]+b[j,i];
end;
end;
for i:=1 to p do
begin
readln(x,y);
writeln(a[x,y]);
end;
close(output);
end.