/*#牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432*/
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<string, int>> a(n,{"", 0});
for (int i = 0; i < n; i++){
cin >> a[i].first;
}
string s;
int num = 0;
int x;
cin >> x;
while(x--){
cin >> s;
if (find_if(a.begin(), a.end(),[&](const auto& p){return p.first == s;}) != a.end()){
int index = distance(a.begin(), find_if(a.begin(), a.end(),[&](const auto& p){return p.first == s;}));//---------find_if()可自定义查找的函数,当return 1 时会返回当前的迭代器;distance计算两迭代器之间的距离
a[index].second++;
}
else num++;
}
for (int i = 0; i < n; i++){
cout << a[i].first << " : " << a[i].second << endl;
}
cout << "Invalid : " << num;
}
// 64 位输出请用 printf("%lld")