program sword;
var
aa:array[1..1000] of char;
aaa:array[1..1000] of byte;
i,j,n,m,s1,s2,s3,sum2,sum3:longint;
c:char;
begin
assign(input,'sword.in');
reset(input);
assign(output,'sword.out');
rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(aa[i]);
aaa[i]:=0;
end;
readln(m);
s1:=0;
s2:=0;
s3:=0;
sum2:=0;
sum3:=9999;
for i:=1 to m do
begin
readln(c);
for j:=1 to n do
if c=aa[j] then
begin
if aaa[j]=0 then
begin
inc(s1);
aaa[j]:=1;
inc(s2);
end;
inc(s3);
if (sum2<s2) then
begin
sum2:=s2;
sum3:=s3;
end
else if (sum2=s2) and (s3<sum3) then
sum3:=s3;
end;
end;
writeln(s1);
writeln(sum2);
close(input);
close(output);
End.