#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
string str;
map<string, int> people;
map<string, int> contribute;
vector<string> v;
for(int i = 0; i < n; ++i){
cin >> str;
people[str] = 1;
contribute[str] = 0;
v.push_back(str);
}
v.push_back("Invalid");
cin >> n;
for(int i = 0; i < n; ++i){
cin >> str;
if(people[str] == 1){
contribute[str] ++;
}else{
contribute["Invalid"] ++;
}
}
for(auto it : v){
cout << it << " : " << contribute[it] << endl;
}
}
// 64 位输出请用 printf("%lld")