Hide

Problem D
Mæting

Languages en is

As a preschool teacher you are used to kids not coming to school due to sickness. A part of your job is taking attendance, so you have a list of which students came to school on which day. Today is Wednesday and you are look at the attendance on Monday and Tuesday. You are interested in which students came to school on both Monday and Wednesday.

To adhere to local privacy laws no names appear on the list of attendance. The children are instead represented by numbers. So you want to know what numbers appear on both lists.

Input

The first line of the input contains two integers $n$ and $m$ ($1 \leq n, m \leq 100$). The second line of the input contains $n$ distinct integers $x$ ($1 \leq x \leq 10^5$). The third line of the input contains $m$ distinct integers $x$ ($1 \leq x \leq 10^5$). The second line describes the students that attended on Monday, and the third line describes thee students that attended on Tuesday.

Output

The output should contain those numbers in the output that appear on both the second and the third line of the input, in the order they appear on the second line.

Sample Input 1 Sample Output 1
3 3
1 2 3
1 2 4
1 2
Sample Input 2 Sample Output 2
3 2
1 6 2
2 4
2
Sample Input 3 Sample Output 3
8 7
1 4 3 2 5 8 7 6
9 1 7 8 3 2 4
1 4 3 2 8 7

Please log in to submit a solution to this problem

Log in