A = gets.chomp S = gets.chomp puts S.chars.map { _1 =~ /\d+/ ? A[_1.to_i] : _1 }.join