#yuki610 n=int(raw_input()) a=map(int,raw_input().split()) b=map(int,raw_input().split()) m=[0 for i in xrange(n+1)] for i,x in enumerate(a): m[x]=i ma=-1 res=[] for y in b: if ma<=m[y]: ma=m[y] res.append(y) res.sort() for i in xrange(len(res)): print res[i]