import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Scanner;
public class Main {
public static Scanner sc = new Scanner(System.in);
static int mod = 1_000_000_000 + 7;
public static void main(String[] args) {
int n = sc.nextInt();
int[] list1 = new int[n];
for(int i=0;i<n;i++){
list1[i] = sc.nextInt();
}
int m = sc.nextInt();
int[] list2 = new int[m];
for(int i=0;i<m;i++){
list2[i] = sc.nextInt();
}
boolean flag = false;
int i = 0;
int j = 0;
while (i < n && j < m){
if(list1[i]== list2[j]){
if(!flag) {
System.out.print(list1[i]);
flag = true;
}else {
System.out.print(" " + list1[i]);
}
i++;
j++;
}else if(list1[i] < list2[j]){
i ++;
}else {
j ++;
}
}
System.out.println();
}
}
/*
4
1 2 3 4
5
1 2 3 5 6
1 2 3
32
1 2 5 7 12 13 16 18 19 21 22 24 26 28 30 32 33 35 38 40 42 47 48 51 54 55 57 59 60 61 62 63
49
1 4 7 8 10 12 14 16 19 20 21 23 25 27 29 30 31 34 37 39 40 45 49 50 55 59 62 64 66 67 68 69 70 71 72 73 74 76 78 81 83 87 88 89 90 92 93 94 98
1 7 12 16 19 21 30 40 55 59 62
*/