n = int(input())
l1 = list(map(int, input().split()))
m = int(input())
l2 = list(map(int, input().split()))
res = []
i, j = 0, 0
while i < n and j < m:
if l1[i] == l2[j]:
res.append(l1[i])
i += 1
j += 1
elif l1[i] > l2[j]:
j += 1
else:
i += 1
print(*res)