Time limit
2s
Memory limit
256 MB
You are given two lists of names. The first list contains names of people not heard of, and the second list contains names of people not seen. Find the names that appear in both lists, sort them in lexicographic order, and print them.
The first line contains two integers N and M, the number of names in the first and second lists.
The next N lines contain the names in the first list, one per line. The following M lines contain the names in the second list, one per line.
Each name consists only of lowercase English letters with no spaces, and its length is at most 20. N and M are positive integers not greater than 500,000.
No name appears more than once within the same list.
Print the number of names that appear in both lists on the first line.
Then print those names in lexicographic order, one per line.