#include<iostream>
#include<string>
#include<map>
using namespace std;
#define int long long
const int N = 10010;
map<string,pair<bool,bool>> mp1,mp2;
int st[N];
signed main(){
int n,m;
cin>>n>>m;
int num = 0;
for(int i = 1;i<=n+m;i++){
string s;
cin>>s;
for(int j = 0;j<s.length();j++){
s[j] = tolower(s[j]);
}
if(i<=n){
mp1[s].first = true;
}
if(i>n&&mp1[s].first==true&&mp1[s].second == false){
mp1[s].second = true;
num++;
}
}
cout<<num<<'\n'<<mp1.size();
return 0;
}