#include<bits/stdc++.h>
#define lowbit(x) ((x)&-(x))
using namespace std;
typedef long long ll;
const int N=1e5+1;
ll n,m;
ll a[N],ans[N];
bool find(ll x){
ll left=1,right=n;
while(left<right){
ll mid=left+(right-left)/2;
if(a[mid]>=x){
right=mid;
} else {
left=mid+1;
}
}
if(a[left]==x){return true;}
else return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
ll cnt=0;
for(int i=1;i<=m;i++){
ll y;
cin>>y;
if(find(y)){ans[++cnt]=y;}
}
sort(ans+1,ans+1+cnt);
for(int i=1;i<=cnt;i++){
cout<<ans[i]<<" ";
}
return 0 ;
}