#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
int n, m;
string name;
while (cin >> n) {
vector<string> arr(n);
map<string, int> dict;
int invalid_count = 0;
for (int i = 0; i < n; i++) {
cin >> name;
arr[i] = name;
dict[name] = 0;
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> name;
if (dict.find(name) != dict.end()) {
dict[name]++;
} else {
invalid_count++;
}
}
for (auto s : arr) {
//cout << s << endl;
cout << s << " : " << dict[s] << endl;
}
cout << "Invalid " << ": " << invalid_count << endl;
}
return 0;
}