#include<bits/stdc++.h>
using namespace std;
int a[201],b[201];
int main()
{
freopen("rps.in","r",stdin);
freopen("rps.out","w",stdout);
int n,na,nb,x=1,y=1,soa=0,sob=0,i,flag=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:
sob++;
break;
case 2:
case 3:
soa++;
break;
}
break;
case 1:
switch(b[y])
{
case 0:
case 3:
soa++;
break;
case 1:
break;
case 2:
case 4:
sob++;
break;
}
break;
case 2:
switch(b[y])
{
case 0:
case 3:
sob++;
break;
case 1:
case 4:
soa++;
break;
case 2:
break;
}
break;
case 3:
switch(b[y])
{
case 0:
case 1:
sob++;
break;
case 2:
case 4:
soa++;
break;
case 3:
break;
}
break;
case 4:
switch(b[y])
{
case 0:
case 1:
soa++;
break;
case 2:
case 3:
sob++;
break;
case 4:
break;
}
break;
}
x++;
y++;
flag++;
}
while(flag<n);
cout<<soa<<' '<<sob;
return 0;
}