import java.util.Scanner;


public class Dive {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		/*for(int i = 33; i < 127; i++){
			char temp = (char) i;
			System.out.println(temp);
		}*/
		
		Dive dive = new Dive();
		
		
		while(true) {
			Picture picture = readInput(dive);
			if(picture == null) break;
			picture.writePicture3();
		}

	}
	
	public static Picture readInput(Dive dive) {
		Picture picture;
		
		String str = sc.nextLine();
		String[] split = str.split("[ ']");		
		int y = Integer.parseInt(split[0]);
		int x = Integer.parseInt(split[1]);
		
		/*int y = sc.nextInt();
		int x = sc.nextInt();
		String str = sc.next().replace("'", " ").trim();*/
		
		if(y == 0) {
			//System.out.println("Konec");
			return null;
			
		}
		
		//sc.nextLine();
		
		char[][] picture1 = readPicture(y, x);
		sc.nextLine();
		char[][] picture2 = readPicture(y, x);
		sc.nextLine();
		
		picture = dive.new Picture(y, x, split[2].charAt(0), picture1, picture2);	
		
		//System.out.println(picture);
		
		return picture;
	}
	
	public static char[][] readPicture(int y, int x) {
		char[][] picture = new char[y][];
		
		for(int i = 0; i < y; i++) {
			String str = sc.nextLine();
			//System.out.println(str);
			picture[i] = str.toCharArray();
		}
		
		return picture;
	}
	
	class Picture {
		int y;
		int x;
		char ch;
		char[][] picture1;
		char[][] picture2;
		char[][] picture3;
		char[][] figure1;
		char[][] figure2;
		int velocityX;
		int velocityY;
		int firstX;
		int firstY;
		int secondX;
		int secondY;
		
		public Picture(int y, int x, char ch, char[][] picture1, char[][] picture2) {
			this.y = y;
			this.x = x;
			this.ch = ch;
			this.picture1 = picture1;
			this.picture2 = picture2;
			this.figure1 = separateFigure(picture1, false);
			this.figure2 = separateFigure(picture2, true);
			calculateVelocities();
			calculatePicture3();
		}
		
		public char[][] separateFigure(char[][] picture, boolean second) {
			char[][] figure = new char[y][x];
			boolean first = true;
			
			for(int i = 0; i < y; i++) {
				for(int j = 0; j < x; j++) {
					if(picture[i][j] == ch) {
						figure[i][j] = ch;
						
						if(first){
							first = false;
							if(second) {
								this.secondX = j;
								this.secondY = i;
							} else {
								this.firstX = j;
								this.firstY = i;
							}
						}
					}
				}
			}
			
			return figure;
		}
		
		public void calculateVelocities() {
			this.velocityX = this.secondX - this.firstX;
			this.velocityY = this.secondY - this.firstY;
		}
		
		public void calculatePicture3() {
			this.picture3 = new char[y][x];
			
			for(int i = this.secondY; i < y; i++) {
				for(int j = this.secondX; j < x; j++) {
					if(this.figure2[i][j] == this.ch) {
						int possitionY = i + this.velocityY;
						int possitionX = j + this.velocityX;
						//System.out.println(possitionX + " " + possitionY);
						
						if(possitionX < x && possitionX >= 0 && possitionY < y && possitionY >= 0) {
							this.picture3[possitionY][possitionX] = this.ch;
						}
					} else {
						this.picture3[i][j] = (char) 5;
					}
				}
			}
			
			for(int i = 0; i < y; i++) {
				for(int j = 0; j < x; j++) {
					//System.out.print(picture3[i][j]);
					if(picture3[i][j] != this.ch) {
						if(picture1[i][j] != this.ch) {
							picture3[i][j] = picture1[i][j];
						} else {
							picture3[i][j] = picture2[i][j];
						}
					}
				}
				//System.out.println();
			}
		}
		
		public void writePicture3() {
			for(int i = 0; i < y; i++) {
				for(int j = 0; j < x; j++) {
					System.out.print(picture3[i][j]);
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}