#include<stdio.h>
#define N 500

int a[N],n1,n2,number;

int searchNumber(int x){
  int i;
  for(i=0;i<n2;i++){
    if( a[i] == x ) return a[i];
  }
  return -1;
}

int main(){

  int i,j;
  int b[500];
  scanf("%d",&n1);
  for(i=0;i<n1;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&b[i]);
  }

  for(i=0;i<n2-1;i++){
    number = search(b[i]);
    if( number != -1 ) printf("%d ",number);
  }

  number = search(b[i]);
  if(number != -1 ) printf("%d\n",number);
  return 0;
}