N=gets.to_i A,B=$<.map{|s|s.split.map &:to_i} ans = [] B.each{|x| idx = A.index(x) if idx A.shift(idx) ans << x end } puts ans.sort