题目描述
Problem Description
Given two sequences of positive integers, $A=(A_1,A_2,\dots,A_N)$ with $ N $ elements and $B=(B_1,B_2,\dots,B_M)$ with $ M $ elements, find all elements that are contained in both $ A $ and $ B $ and output them in ascending order.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ A_1 $ $ A_2 $ $\dots$ $ A_N $ $ B_1 $ $ B_2 $ $\dots$ $ B_M $
Output Format
Output all elements that satisfy the condition, separated by spaces, in ascending order.
Sample Input and Output
Sample Input #1
6 4
60 50 40 30 20 10
53 60 25 40
Sample Output #1
40 60
Sample Input #2
3 1
1 2 3
123
Sample Output #2
Notes/Hints
Constraints
- $1 \leq N, M \leq 1000$
- $1 \leq A_i \leq 10^9$
- $1 \leq B_i \leq 10^9$
- $A_i \neq A_j$ if $i \neq j$
- $B_i \neq B_j$ if $i \neq j$
- All inputs are integers
Sample Explanation 1
Note that the output must be in ascending order, so a submission like 60 40 would be incorrect.
Sample Explanation 2
There may be no elements that satisfy the condition.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
6 4
60 50 40 30 20 10
53 60 25 40
样例输出
40 60