Problem

5 /11


Intersection of many

Problem

Given two unordered sets of integers (maybe with repetitions). Print without repetitions in ascending order all those numbers that occur in both sets.
 
Input
The first line of the input stream contains two space-separated integers N and M (1 ≤ N, M ≤ 300,000) — the number of elements of the first and second sets, respectively. The next two lines contain first N numbers of the first set, and then M numbers of the second set. Numbers are separated by spaces. Each of these numbers falls between 0 and 105.
 
Output
It is necessary to display in ascending order without repetitions all the numbers that are included in both the first and second set. Separate numbers with one space. If there are no such numbers, then nothing should be output.
 
Input Output
116
2 4 6 8 10 12 10 8 6 4 2
3 6 9 12 15 18
6 12