#include<cstdio>
#include<iostream>
using namespace std;
main()
{
freopen("rps.in","r",stdin);
freopen("rps.out","w",stdout);
int a[201],b[201],i,n,na,nb,s=0,x=1,y=1,sa=0,sb=0;
cin>>n>>na>>nb;
for(i=1;i<=na;i++)
cin>>a[i];
for(i=1;i<=nb;i++)
cin>>b[i];
do
{
if(x>na)
x=1;
if(y>nb)
y=1;
switch(a[x])
{
case 0:
switch(b[y])
{
case 0:
break;
case 1:
case 4:
sb++;
break;
case 2:
case 3:
sa++;
break;
}
break;
case 1:
switch(b[y])
{
case 0:
case 3:
sa++;
break;
case 1:
break;
case 2:
case 4:
sb++;
break;
}
break;
case 2:
switch(b[y])
{
case 0:
case 3:
sb++;
break;
case 1:
case 4:
sa++;
break;
case 2:
break;
}
break;
case 3:
switch(b[y])
{
case 0:
case 1:
sb++;
break;
case 2:
case 4:
sa++;
break;
case 3:
break;
}
break;
case 4:
switch(b[y])
{
case 0:
case 1:
sa++;
break;
case 2:
case 3:
sb++;
break;
case 4:
break;
}
break;
}
x++;
y++;
s++;
}while(s<n);
cout<<sa<<' '<<sb;
}