import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int N = kb.nextInt();
int M = kb.nextInt();
kb.nextLine();
HashSet<String> set = new HashSet<>();
for(int i=0; i<N; i++) {
set.add(kb.nextLine());
}
ArrayList<String> answer = new ArrayList<>();
for(int i=0; i<M; i++) {
String name = kb.nextLine();
if(set.contains(name)) {
answer.add(name);
}
}
Collections.sort(answer);
System.out.println(answer.size());
for(String name: answer) {
System.out.println(name);
}
}
}