program ploksteles_su_skylutemis;
{ 94 u‘davinys }
  const MAX = 100; { maksimalus plokžtel‚s dydis }
  type plokstele = array [1..MAX, 1..MAX] of boolean;
       { true - kvadrat‚lis ižkirptas }

  function skylutes (n : integer; var pl1, pl2 : plokstele) : integer;
    var s : array [1..8] of integer;
        { kiek skylu‡i— matosi u‘d‚jus antr…j… plokžtelŠ ant pirmosios }
        { atitinkamai apvertus ar pasukus antr…j… plokžtelŠ }
        i, j, min : integer;
  begin
    for i := 1 to 8 do
      s[i] := 0;
    for i := 1 to n do
      for j := 1 to n do
         if pl1[i, j] { jei skylut‚ pirmajame kvadrat‚lyje }
            then begin
                   if pl2[i, j] then s[1] := s[1] + 1;
                   if pl2[j, n - i + 1] then s[2] := s[2] + 1;
                   if pl2[n - i + 1, n - j + 1] then s[3] := s[3] + 1;
                   if pl2[n - j + 1, i] then s[4] := s[4] + 1;
                   if pl2[i, n - j + 1] then s[5] := s[5] + 1;
                   if pl2[n - j + 1, n - i + 1] then s[6] := s[6] + 1;
                   if pl2[n - i + 1, j] then s[7] := s[7] + 1;
                   if pl2[j, i] then s[8] := s[8] + 1;
                 end;
    min := s[1];
    for i := 2 to 8 do
      if s[i] < min
         then min := s[i];
    skylutes := min;
  end;

  var f: text;
      vardas: string;
      rez, i, j, k, s1, s2, n: integer;
      pl1, pl2: plokstele;
begin
  assign (f, 'PLOKST.DAT');
  reset (f);
  readln (f, n);
  for i := 1 to n do
    for j := 1 to n do
      begin
        pl1[i, j] := false;
        pl2[i, j] := false;
      end;
  { nuskaitysime skylu‡i— koordinates }
  readln (f, s1, s2);
  for k := 1 to s1 do
    begin
      readln (f, i, j);
      pl1[i, j] := true;
    end;
  for k := 1 to s2 do
    begin
      readln (f, i, j);
      pl2[i, j] := true;
    end;
  close (f);
  rez := skylutes (n, pl1, pl2);
  writeln (rez);
end.

