A = gets.chomp S = gets.chomp a_array = A.chars s_array = S.chars output = "" s_array.each_with_index do |s, i| if /\d/.match(s) output << a_array[s_array[i].to_i] else output << s end end puts output