/**************************************************************** 
 * Description: 
 * Author: Alex Li
 * Date: 2024-01-22 17:33:46
 * LastEditTime: 2024-01-22 20:35:18
****************************************************************/
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
 int a[100001],b[100001];
 int n,m;
bool bitSearch(int c){
    bool d=false;
   int mid;
   int l=0,r=m;
   while(l<=r){
       mid=(l+r)/2;
       if(b[mid]==c){
           d=true;
           break;
       }
       if(b[mid]>=c){
           r=mid-1;
       }
       else{
           l=mid+1;
       }
   }
    return d;
 }
int main(){
  
   cin>>n>>m;
   for (int i =1; i <=n; i++){
    cin>>a[i];
   }
   for (int i = 0; i <m; i++){
    cin>>b[i];
   }
   sort(b,b+m);
  
   
   for (int i =1; i <=n; i++){
    if(bitSearch(a[i]))cout<<a[i]<<' ';
   }
   
return 0;
}