// Arup Guha
// 5/5/2016
// Solution to 2004 MCPC Problem E: Permutation Code

import java.util.*;

public class e {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int x = stdin.nextInt();

		// Process each case.
		while (x != 0) {

			// Get input can calculate necessary values.
			String symbols = stdin.next();
			String perm = stdin.next();
			String cipher = stdin.next();
			int n = cipher.length();
			int d = ((int)(Math.pow(n, 1.5) + x))%n;

			// Look up table into symbols.
			int[] sMap = new int[256];
			Arrays.fill(sMap, -1);
			for (int i=0; i<symbols.length(); i++)
				sMap[(int)symbols.charAt(i)] = i;

			// Calculate character d.
			char[] plain = new char[n];
			plain[d] = perm.charAt(sMap[cipher.charAt(d)]);

			// Now, work backwards.
			for (int i=d-1+n; i>d; i--) {

				// Avoid overflow.
				int curI = i%n;
				int prevI = (i+1)%n;

				// xor to recovier index for p array for this character.
				plain[curI] = perm.charAt(sMap[cipher.charAt(curI)] ^ sMap[plain[prevI]]);
			}

			// Ta da!
			System.out.println(new String(plain));

			// Get next case.
			x = stdin.nextInt();
		}
	}
}