#include <iostream>
#include <string>
using namespace std;
int main(){
int n1,n2;
cin >> n1;
string str1[n1];
int cnt = 0; //记录每个候选人的票数
int valid = 0; //记录有效投票的总数
for(int i = 0; i < n1; i++){
cin >> str1[i];
}
cin >> n2;
string str2[n2];
for(int i = 0; i < n2; i++){
cin >> str2[i];
}
for(int i = 0; i < n1; i++){
cnt = 0;
for(int j = 0; j < n2; j++){
if(str1[i] == str2[j]){
cnt++;
valid++;
}
}
if(cnt != 0){
cout << str1[i] << " " << ":" <<" "<< cnt <<endl;
}
else{
cout << str1[i] << " " << ":" <<" "<< 0 <<endl; //记录没得票的候选人,票数为0
}
}
cout <<"Invalid"<< " " << ":" <<" "<< (n2-valid) <<endl;
return 0;
}
#include <string>
using namespace std;
int main(){
int n1,n2;
cin >> n1;
string str1[n1];
int cnt = 0; //记录每个候选人的票数
int valid = 0; //记录有效投票的总数
for(int i = 0; i < n1; i++){
cin >> str1[i];
}
cin >> n2;
string str2[n2];
for(int i = 0; i < n2; i++){
cin >> str2[i];
}
for(int i = 0; i < n1; i++){
cnt = 0;
for(int j = 0; j < n2; j++){
if(str1[i] == str2[j]){
cnt++;
valid++;
}
}
if(cnt != 0){
cout << str1[i] << " " << ":" <<" "<< cnt <<endl;
}
else{
cout << str1[i] << " " << ":" <<" "<< 0 <<endl; //记录没得票的候选人,票数为0
}
}
cout <<"Invalid"<< " " << ":" <<" "<< (n2-valid) <<endl;
return 0;
}