https://www.acmicpc.net/problem/1764
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#pragma warning(disable: 4996)
using namespace std;
int n, m;
int main(){
set<string> s;
scanf("%d %d", &n, &m);
string str;
for(int j=0;j<n;j++){
cin>>str;
s.insert(str);
}
int answer = 0;
vector<string> ans;
for(int i=0;i<m;i++){
cin>>str;
if(s.find(str) != s.end()){
answer++;
ans.push_back(str);
}
}
printf("%d\n", answer);
sort(ans.begin(), ans.end());
for(int i=0;i<ans.size();i++)
cout<< ans[i]<<endl;
return 0;
}