import sys

while True:
	line = input()
	if line == "0 0 ' '":
		break
		
	x, y, char = line.split()
	x, y = int(x), int(y)
	char = char[1]
	first = [list(input()) for x in range(x)]
	input()
	second = [list(input()) for x in range(x)]
	
	background = [[(first[i][j] if first[i][j] != char else second[i][j]) for j in range(y)] for i in range(x)]
	
	for index, line in enumerate(first):
		try:
			pos = line.index(char)
		except ValueError:
			pass
		if pos != -1:
			pos1 = index, pos
			break
			
	
	for index, line in enumerate(second):
		try:
			pos = line.index(char)
		except ValueError:
			pass
		if pos != -1:
			pos2 = index, pos
			break
	
	speed = pos2[0] - pos1[0], pos2[1] - pos1[1]
	# pos = pos2[0] + speed[0], pos2[1] + speed[1]
	
	for indexx, line in enumerate(second):
		for indexy, ch in enumerate(line):
			if ch == char and 0 <= indexx + speed[0] < x and 0 <= indexy + speed[1] < y:
				background[indexx + speed[0]][indexy + speed[1]] = char
				
	print("\n".join(("".join(x) for x in background)))
	print()
	input()