A,S = gets.chomp, gets.chomp output = "" S.chars.each { |s| /\d/.match(s) ? (output << A[s.to_i]) : (output << s)} puts output