program p2019;
var n,na,nb,i,j,k,fa,fb:integer;
a,b:array[1..200]of integer;
begin
assign(input,'rps.in'); reset(input);
assign(output,'rps.out'); rewrite(output);
readln(n,na,nb);
for i:=1 to na do read(a[i]); readln;
for i:=1 to nb do read(b[i]); i:=1; j:=1;
for k:=1 to n do
begin
if i>na then i:=1;
if j>nb then j:=1;
if a[i]<>b[j] then
begin
if a[i]=0 then
if (b[j]=2) or (b[j]=3) then inc(fa) else inc(fb);
if a[i]=1 then
if (b[j]=0) or (b[j]=3) then inc(fa) else inc(fb);
if a[i]=2 then
if (b[j]=1) or (b[j]=4) then inc(fa) else inc(fb);
if a[i]=3 then
if (b[j]=2) or (b[j]=4) then inc(fa) else inc(fb);
if a[i]=4 then
if (b[j]=0) or (b[j]=1) then inc(fa) else inc(fb);
end;
inc(i); inc(j);
end;
write(fa,' ',fb);
close(input); close(output);
end.