#include <stdio.h>
#define N 10000
#define M 500

int main(){
  int n,q,key;
  int s[N],t[M],p[M];
  int i,j,flag=0,found=1;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  for(i=0;i<n;i++){
    j=0;
    key=s[i];
    while(t[j]!=key){
      j++;
      if(j==q){
	found=0;
	break;
      }
    }
    if(found==1){
      p[flag]=key;
      flag++;
    }
  }
  for(i=0;i<flag;i++){
    if(flag==0){
      printf("%d\n",flag);
      break;
    }
    if(i==flag){
      printf("%d\n",p[i]);
      break;
    }
    printf("%d ",p[i]);
  }
  return 0;
}