n,m=map(int,input().split())
val=input()
keys=val.split()
u=input()
fp=u.split()
for i in range(n):
if(keys[i] in fp):
print(keys[i],end=" ")
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,i,j,a[10001],b[10001];
cin>>n>>m;
for(i=0;i<n;i++){
cin>>a[i];
}
for(i=0;i<m;i++){
cin>>b[i];
}
vector<int>v;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(a[i]==b[j]){
v.push_back(a[i]);
}
}
}
for(i=0;i<v.size();i++){
cout<<v[i]<<" ";
}
return 0;
}
1712A - Wonderful Permutation | 1712D - Empty Graph |
1712B - Woeful Permutation | 1712C - Sort Zero |
1028B - Unnatural Conditions | 735B - Urbanization |
746C - Tram | 1278B - A and B |
1353D - Constructing the Array | 1269C - Long Beautiful Integer |
1076A - Minimizing the String | 913C - Party Lemonade |
1313A - Fast Food Restaurant | 681A - A Good Contest |
1585F - Non-equal Neighbours | 747A - Display Size |
285A - Slightly Decreasing Permutations | 515C - Drazil and Factorial |
1151E - Number of Components | 1151F - Sonya and Informatics |
556A - Case of the Zeros and Ones | 867A - Between the Offices |
1569A - Balanced Substring | 260A - Adding Digits |
1698C - 3SUM Closure | 1029B - Creating the Contest |
1421A - XORwice | 1029A - Many Equal Substrings |
1675D - Vertical Paths | 1271C - Shawarma Tent |