n = gets.to_i s = gets.split.map(&:to_i) t = gets.split.map(&:to_i) w = Array.new(n+1) l = Array.new(n+1) s.each_with_index{|v, i| w[v] = i } t.inject(-1) do |j, v| if w[v] > j l[v] = true w[v] else j end end ans = (1..n).select {|v| l[v] } puts ans