#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>

using namespace std;
int main() {
	while(1) {
	int m, n;
	char waste, znak;
	cin >> m >> n >> waste >> znak >> waste;
	if ((m == 0) && (n == 0)) return 0;
	string frame1[m], frame2[m], frame3[m];
	int i = 0, j = 0;
	string wasteLine;
	getline(cin, wasteLine);
	for (i = 0; i < m; i++) {
		string line;
		getline(cin, line);
		frame1[i] = line;
//		cout << frame1[i] << endl;
	}
	getline(cin, wasteLine);
	for (i = 0; i < m; i++) {
		string line;
		getline(cin, line);
		frame2[i] = line;
//		cout << frame2[i] << endl;
	}
	for (i = 0; i < m; i++) {
		string tmpLine; 
		for (j = 0; j < n; j++) {
			if (frame1[i][j] != znak) tmpLine = tmpLine + frame1[i][j]; else tmpLine = tmpLine + frame2[i][j];
		}
		frame3[i] = tmpLine;
//		cout << frame3[i] << endl;
	}
	int pos1X = -1;
	int pos1Y = -1;
	int pos2X = -1;
	int pos2Y = -1;
	for (i = 0; i < m; i++) {
		pos1Y = i;
		pos1X = frame1[i].find_first_of(znak);
		if (pos1X != -1) break;
	}	
	for (i = 0; i < m; i++) {
		pos2Y = i;
		pos2X = frame2[i].find_first_of(znak);
		if (pos2X != -1) break;
	}
	int posunX = pos2X - pos1X;
	int posunY = pos2Y - pos1Y;
//	cout << "posun X:posun Y " << posunX << " " << posunY << endl;
	for (i = 0; i < m; i++) {
		for (j = 0; j < n; j++) {
			if (frame2[i][j] == znak) { 
//				cout << "nasiel som znak [" << i << "][" << j << "]" << endl;
//				cout << "nova pozicia by mala byt" << i + posunY << " " << j + posunX << endl;	
				if ((i + posunY) < m && (i + posunY) >= 0 && (j + posunX) < n && (j + posunX) >= 0) {
					//cout << "splnila sa podmienka " << endl;
					frame3[i + posunY][j + posunX] = znak;
				}
			}

		}
//		cout << frame3[i] << endl;
	}	
	for (i = 0; i < m; i++) {
		cout << frame3[i] << endl;
	}
	cout << endl;
	}
	return 0;
}