import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PriorityQueue<String> queue = new PriorityQueue<>();
		
		String[] s = br.readLine().split(" ");
		int N = Integer.parseInt(s[0]);
		int M = Integer.parseInt(s[1]);
		
		Map<String,Integer> map = new HashMap<String,Integer>();

		//듣도 못한 사람
		for(int i=0;i<N;i++) {
			String name = br.readLine();
			map.put(name, 1);
		}
		
		for(int i=0;i<M;i++) {
			String name = br.readLine();
			if(map.containsKey(name)) {
				queue.add(name);
			}
		}
		
		System.out.println(queue.size());
		while(!queue.isEmpty())
			System.out.println(queue.poll());
		
			
	}
}