program robotel;
const prob='robotel';
var fin,fout:text;
    a,b,b1:array[0..16,0..16] of longint;
    t,p,q,s:longint;
    n,m,k,x,y,i,x1,y1,x2,y2,j:byte;

procedure color(i,j:byte);
begin
if a[i,j]<>0 then exit;
a[i,j]:=s;
color(i,j+1);
color(i,j-1);
color(i-1,j);
color(i+1,j);
end;

begin
assign(fin,prob+'.in'); reset(fin);
assign(fout,prob+'.out'); rewrite(fout);
readln(fin,n,m,k);
for i:=1 to k do
begin
readln(fin,x,y);
a[x,y]:=-1;
end;
for i:=0 to n+1 do
begin
a[i,0]:=-1;
a[i,m+1]:=-1;
end;
for i:=0 to m+1 do
begin
a[0,i]:=-1;
a[n+1,i]:=-1;
end;
s:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]=0 then
begin
inc(s);
color(i,j);
end;

readln(fin,p);
for q:=1 to p do
begin
readln(fin,x1,y1,x2,y2,t);
if (a[x1,y1]=-1)or(a[x2,y2]=-1)or((x1+x2+y1+y2+t)mod 2=1)or(a[x1,y1]<>a[x2,y2]) then
writeln(fout,'0') else
begin
for i:=1 to n do
for j:=1 to m do
b[i,j]:=0;
b[x1,y1]:=1;

for s:=1 to t do
begin
for i:=1 to n do
for j:=1 to m do
if a[i,j]<>-1 then
begin
if a[i+1,j]<>-1 then b1[i,j]:=b1[i,j]+b[i+1,j];
if a[i-1,j]<>-1 then b1[i,j]:=b1[i,j]+b[i-1,j];
if a[i,j+1]<>-1 then b1[i,j]:=b1[i,j]+b[i,j+1];
if a[i,j-1]<>-1 then b1[i,j]:=b1[i,j]+b[i,j-1];
end;
b:=b1;
for i:=1 to n do
for j:=1 to m do
b1[i,j]:=0;
end;
writeln(fout,b[x2,y2]);
end;
end;
close(fin);
close(fout);
end.
