	/**
	 * Class for emulating the enigma encoding/decoding
	 */

import java.util.Scanner;

public class Enigma {
	private String innerRotor;
	private String middleRotor;
    private String backplate;
	
	/**
	 * Constructs an enigma emulation with given the rotors and backplate
	 * @param inner character sequence on inner rotor
     * @param middle character sequence on middle rotor
	 * @param back character sequence on the backplate
	 */
	public Enigma(String inner, String middle, String back){
		this.middleRotor = middle;
        this.innerRotor = inner;
        this.backplate = back;
    }
	
	/**
	 * Encodes the message
	 * @param String to be encoded
	 * @return the encoded String
	 */
	public String encode(String message){
    String middleCopy = this.middleRotor;
    String innerCopy = this.innerRotor;
    
		String encMessage = "";
		
		for(int i = 0; i < message.length(); i++){			
			String temp = message.substring(i,i + 1);			
			int tempPos = innerCopy.indexOf(temp);
			
			String buffer = backplate.substring(tempPos, tempPos + 1);
			
			tempPos = middleCopy.indexOf(buffer);
			
			encMessage += backplate.substring(tempPos, tempPos+1);
			
			innerCopy = rotate(innerCopy);
			if (innerCopy.equals(this.innerRotor)) {
        middleCopy = rotate(middleCopy);
      }
		}
		return encMessage;
	}
	
	/**
	 * Shifts plate in decoding/encoding process
	 * @param String of plate being shifted
	 * @return the String of plate now shifted
	 */	
	private String rotate(String rotor){
		return rotor.substring(rotor.length()-1,rotor.length()) +
                           rotor.substring(0,rotor.length()-1);
	}

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String inner = input.nextLine();
        String middle = input.nextLine();
        String back = input.nextLine();
        String message = input.nextLine();

        Enigma coder = new Enigma(inner, middle, back);
        System.out.println(coder.encode(message.substring(0, message.length()-1)) + ".");
    }
}
