n = int(input()) ls1 = list(map(int,input().split())) m = int(input()) ls2 = list(map(int,input().split())) i,j = 0,0 ls = [] while i < n and j < m: if ls1[i] == ls2[j]: ls.append(ls1[i]) i += 1 j += 1 else: if ls1[i] < ls2[j]: i += 1 else: j += 1 ls.sort() print(' '.join(map(str,ls)))