program robotel;
var fin,fout:text;
    ans1,ans:longint;
    s1,s,r,t,j,i,x,y,l,q1,q2,n,m,k,x2,y2:integer;
    a,b,e:array[0..16,0..16] of integer;
    c:array[0..110,0..110] of integer;
    o1,o2,w,zero:array[0..110] of integer;
procedure back(x,y:integer);
begin
 if b[x,y]=3 then inc(w[s1]);
 s1:=s1+1;
 if s+s1<r then
  begin
   if b[x,y-1]<>1 then back(x,y-1);
   if b[x,y+1]<>1 then back(x,y+1);
   if b[x-1,y]<>1 then back(x-1,y);
   if b[x+1,y]<>1 then back(x+1,y);
  end;
 s1:=s1-1;
end;
procedure back2(i:integer);
var j:integer;
    z:longint;
begin
if r=0 then ans:=(ans+ans1) mod 666013 else
begin
 for j:=0 to r do
  begin
   z:=ans1;
   ans1:=(ans1*c[i,j*2]) mod 666013;
   r:=r-j*2;
   back2(i+1);
   r:=r+j*2;
   ans1:=z;
  end;
end;
end;
procedure back1(x,y:integer);
var i,j:integer;
begin
 if b[x,y]=5 then
  begin
   if s=r then ans:=(ans+1) mod 666013 {else
    begin
     e:=b;
     o1[s]:=x; o2[s]:=y;
     for i:=1 to s do
      begin
       b[o1[i],o2[i]]:=1;
       for j:=0 to r-s+1 do c[i,j]:=1;
      end;
     for i:=1 to s-1 do
      begin
       w:=zero;
       b[o1[i],o2[i]]:=3;
       back(o1[i],o2[i]);
       c[i]:=w;
      end;
     r:=r-s;
     back2(1);
     r:=r+s;
     b:=e;
    end;}
  end else
  begin
  s:=s+1;
  o1[s]:=x;
  o2[s]:=y;
  b[x,y]:=1;
  if s<r then
   begin
    if b[x,y-1]<>1 then back1(x,y-1);
    if b[x,y+1]<>1 then back1(x,y+1);
    if b[x-1,y]<>1 then back1(x-1,y);
    if b[x+1,y]<>1 then back1(x+1,y);
   end;
  b[x,y]:=0;
  s:=s-1;
 end;
end;
begin
assign(fin,'robotel.in'); reset(fin);
assign(fout,'robotel.out'); rewrite(fout);
readln(fin,n,m,k);
for i:=1 to n do
 begin
  a[i,0]:=1;
  a[i,m+1]:=1;
 end;
for i:=1 to m do
 begin
  a[0,i]:=1;
  a[n+1,i]:=1;
 end;
for i:=1 to k do
 begin
  readln(fin,x,y);
  a[x,y]:=1;
 end;
readln(fin,t);
for j:=1 to t do
 begin
  b:=a;
  readln(fin,x,y,x2,y2,r);
  if ((x+y+x2+y2+r) mod 2)<>0 then writeln(fout,0) else
   begin
    q1:=x-x2; if q1<0 then q1:=-q1;
    q2:=y-y2; if q2<0 then q2:=-q2;
    if q1+q2>r then writeln(fout,0) else
     begin
      if (b[x,y]=1) or (b[x2,y2]=1) then writeln(fout,0) else
       begin
        ans:=0;
        b[x,y]:=4;
        b[x2,y2]:=5;
        if x>=x2 then
         begin
          l:=x+((r-q1-q2) div 2)+1;
          if l<=n then
           begin
            for i:=1 to m do b[l,i]:=1;
           end;
          l:=x2-((r-q1-q2) div 2)-1;
          if l>=1 then
           begin
            for i:=1 to m do b[l,i]:=1;
           end;
         end else
         begin
          l:=x-((r-q1-q2) div 2)-1;
          if l>=1 then
           begin
            for i:=1 to m do b[l,i]:=1;
           end;
          l:=x2+((r-q1-q2) div 2)+1;
          if l<=n then
           begin
            for i:=1 to m do b[l,i]:=1;
           end;
         end;
         if y>y2 then
         begin
          l:=y+((r-q1-q2) div 2)+1;
          if l<=m then
           begin
            for i:=1 to n do b[i,l]:=1;
           end;
          l:=y2-((r-q1-q2) div 2)-1;
          if l>=1 then
           begin
            for i:=1 to n do b[i,l]:=1;
           end;
         end else
           begin
          l:=y-((r-q1-q2) div 2)-1;
          if l>=1 then
           begin
            for i:=1 to n do b[i,l]:=1;
           end;
          l:=y2+((r-q1-q2) div 2)+1;
          if l<=m then
           begin
            for i:=1 to n do b[i,l]:=1;
           end;
          end;
        back1(x,y);
        writeln(fout,ans);
       end;
     end;
   end;
 end;
close(fout);
end.



