#include<bits/stdc++.h>
using namespace std;
#define int long long
#define shabi ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int n,m,a[1000010],b[1000010];
signed main(){
shabi;
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=m;i++) cin>>b[i];
sort(b+1,b+m+1);
for(int i=1;i<=n;i++){
int k=a[i];
int l=0,r=m+1;
b[l]=INT_MIN,b[r]=INT_MAX;
while(l+1<r){
int mid=l+r>>1;
if(b[mid]<k) l=mid;
else r=mid;
}if(b[r]==k) cout<<k<<" ";
}return 0;
}