A = gets.split.map(&:to_i) B = gets.split.map(&:to_i) res = [*1..5] temp = Array.new(5) A.each_with_index do |a, i| temp[i] = res[a - 1] end res = temp.dup B.each_with_index do |b, i| temp[i] = res[b - 1] end res = temp.dup puts res.join(' ')