//infoarena amenzi
type pnod = ^tnod;
tnod = record
x:byte;
c:integer;
next:pnod;
end;
rr= record
head,last:pnod;
end;
var n,m,k,p:integer;
mm : array[1..150] of rr;
a:array[0..3500,1..150] of longint;
y:array[0..3500,1..150] of integer;
tt:array[0..3500] of rr;
procedure addlist(var r:rr; x,c:integer);
var p:pnod;
begin
new(p); p^.x:=x; p^.c:=c; p^.next:=nil;
if r.head= nil then r.head:=p
else r.last^.next:=p;
r.last:=p;
end;
procedure calcul;
var i,j:integer;
p:pnod;
begin
for i:=0 to 3500 do
for j:=1 to n do a[i,j]:=-1;
a[0,1]:=0; addlist(tt[0],1,0);
for j:=0 to 3500 do
for i:=1 to n do
if a[j,i] <> -1 then
begin
p:=mm[i].head;
while p <> nil do
begin
if j+p^.c <= 3500 then
if a[j+p^.c,p^.x] < a[j,i]+y[j+p^.c,p^.x] then
a[j+p^.c,p^.x]:=a[j,i]+y[j+p^.c,p^.x];
p:=p^.next;
end;
end;
end;
procedure citire;
var i,x,z,c:integer;
begin
assign(input,'amenzi.in');reset(input);
assign(output,'amenzi.out'); rewritE(output);
readln(n,m,k,p);
for i:=1 to m do
begin
readln(x,z,c);
addlist(mm[x],z,c);
addlist(mm[z],x,c);
end;
for i:=1 to k do
begin
readln(x,z,c);
y[z,x]:=y[z,x]+c;
end;
for i:=1 to n do addlist(mm[i],i,1);
calcul;
for i:=1 to p do
begin
readln(x,z);
writeln(a[z,x]);
end;
close(input);
close(output);
end;
begin
citire;
end.