Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.

The game is played on the following field.

<image>

Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl, yl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl, yl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.

You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.

A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules.

Input

First 11 lines contains descriptions of table with 9 rows and 9 columns which are divided into 9 small fields by spaces and empty lines. Each small field is described by 9 characters without spaces and empty lines. character "x" (ASCII-code 120) means that the cell is occupied with chip of the first player, character "o" (ASCII-code 111) denotes a field occupied with chip of the second player, character "." (ASCII-code 46) describes empty cell.

The line after the table contains two integers x and y (1 ≤ x, y ≤ 9). They describe coordinates of the cell in table where the last move was done. Rows in the table are numbered from up to down and columns are numbered from left to right.

It's guaranteed that cell where the last move was done is filled with "x" or "o". Also, it's guaranteed that there is at least one empty cell. It's not guaranteed that current state of game is reachable.

Output

Output the field in same format with characters "!" (ASCII-code 33) on positions where the current player can put his chip. All other cells should not be modified.

Examples

Input

... ... ...
... ... ...
... ... ...

... ... ...
... ... ...
... x.. ...

... ... ...
... ... ...
... ... ...
6 4


Output

... ... ... 
... ... ... 
... ... ... 

... ... ... 
... ... ... 
... x.. ... 

!!! ... ... 
!!! ... ... 
!!! ... ... 



Input

xoo x.. x..
ooo ... ...
ooo ... ...

x.. x.. x..
... ... ...
... ... ...

x.. x.. x..
... ... ...
... ... ...
7 4


Output

xoo x!! x!! 
ooo !!! !!! 
ooo !!! !!! 

x!! x!! x!! 
!!! !!! !!! 
!!! !!! !!! 

x!! x!! x!! 
!!! !!! !!! 
!!! !!! !!! 



Input

o.. ... ...
... ... ...
... ... ...

... xxx ...
... xox ...
... ooo ...

... ... ...
... ... ...
... ... ...
5 5


Output

o!! !!! !!! 
!!! !!! !!! 
!!! !!! !!! 

!!! xxx !!! 
!!! xox !!! 
!!! ooo !!! 

!!! !!! !!! 
!!! !!! !!! 
!!! !!! !!! 

Note

In the first test case the first player made a move to lower left cell of central field, so the second player can put a chip only to cells of lower left field.

In the second test case the last move was done to upper left cell of lower central field, however all cells in upper left field are occupied, so the second player can put his chip to any empty cell.

In the third test case the last move was done to central cell of central field, so current player can put his chip to any cell of central field, which is already occupied, so he can move anywhere. Pay attention that this state of the game is unreachable.

Difficulty: MEDIUM
Tags: Implementation

Starter code:

Solutions:
import sys
f = sys.stdin
m = []
for t in range(3):
	ml = [[] for _ in range(3)]
	for _ in range(3):
		map_line = f.readline().split()
		for (i, x) in enumerate(map_line):
			ml[i].append(list(x))
	m.append(ml)
	if t < 2:
		f.readline()
(x, y) = map(int, f.readline().split())
x -= 1
y -= 1
fx = x % 3
fy = y % 3
checked = False
for i in range(3):
	for j in range(3):
		if m[fx][fy][i][j] == '.':
			m[fx][fy][i][j] = '!'
			checked = True
if not checked:
	for i in range(9):
		for j in range(9):
			if m[i // 3][j // 3][i % 3][j % 3] == '.':
				m[i // 3][j // 3][i % 3][j % 3] = '!'
for t in range(3):
	for i in range(3):
		print(' '.join((''.join(x[i]) for x in m[t])))
	if t < 2:
		print()


a = []
for i in range(11):
	inp = input()
	if len(inp) == 0:
		continue
	a.append(list(''.join(inp.split())))
(x, y) = map(int, input().split())
(x, y) = (x % 3 - 1, y % 3 - 1)
np = 0
(sx, xy) = (x * 3, y * 3)
for i in range(3):
	for j in range(3):
		if a[sx + i][xy + j] == '.':
			a[sx + i][xy + j] = '!'
			np += 1
if np == 0:
	(sx, xy) = (0, 0)
	for i in range(9):
		for j in range(9):
			if a[sx + i][xy + j] == '.':
				a[sx + i][xy + j] = '!'
for i in range(9):
	print(' '.join([''.join(a[i][:3]), ''.join(a[i][3:6]), ''.join(a[i][6:])]))
	if i == 2 or i == 5:
		print()


def check(a, b):
	global l
	startX = 3 * a
	startY = 3 * b
	for i in range(3):
		for j in range(3):
			if l[startX + i][startY + j] == '.':
				return True
	return False

def c1(a, b):
	global l
	startX = 3 * a
	startY = 3 * b
	for i in range(3):
		for j in range(3):
			if l[startX + i][startY + j] == '.':
				l[startX + i] = l[startX + i][:startY + j] + '!' + l[startX + i][startY + j + 1:]

def c2(a, b):
	global l
	for i in range(9):
		for j in range(9):
			if (i // 3 != a or j // 3 != b) and l[i][j] == '.':
				l[i] = l[i][:j] + '!' + l[i][j + 1:]
l = []
for i in range(3):
	l.append(input())
input()
for i in range(3):
	l.append(input())
input()
for i in range(3):
	l.append(input())
for i in range(9):
	l[i] = l[i].replace(' ', '')
(m, n) = list(map(int, input().split()))
targetX = (m - 1) % 3
targetY = (n - 1) % 3
if check(targetX, targetY):
	c1(targetX, targetY)
else:
	c2(targetX, targetY)
for i in range(9):
	l[i] = l[i][:3] + ' ' + l[i][3:6] + ' ' + l[i][6:]
for val in range(9):
	if val != 0 and val % 3 == 0:
		print()
	print(l[val])


l = [list(input()) for _ in range(11)]
(x, y) = map(int, input().split())
x -= 1
x += x // 3
y -= 1
y += y // 3
(a, b) = (x % 4 * 4, y % 4 * 4)
f = 0
for i in range(a, a + 3):
	for j in range(b, b + 3):
		if l[i][j] == '.':
			f = 1
			l[i][j] = '!'
if f == 0:
	for i in range(11):
		for j in range(len(l[i])):
			if l[i][j] == '.':
				l[i][j] = '!'
for s in l:
	print(''.join(s))


l = [input() for _ in range(11)]
(x, y) = map(int, input().split())
x -= 1
x += x // 3
y -= 1
y += y // 3
(a, b) = (x % 4 * 4, y % 4 * 4)
r = 11
for i in range(a, a + 3):
	s = l[i][b:b + 3]
	if '.' in s:
		(l[i], r) = (l[i][:b] + s.replace('.', '!') + l[i][b + 3:], 0)
for i in range(r):
	l[i] = l[i].replace('.', '!')
print(*l, sep='\n')


p = [[[], [], []], [[], [], []], [[], [], []]]
for i in range(3):
	(a, b, c) = input().split(' ')
	p[0][0].append(a)
	p[1][0].append(b)
	p[2][0].append(c)
input()
for i in range(3):
	(a, b, c) = input().split(' ')
	p[0][1].append(a)
	p[1][1].append(b)
	p[2][1].append(c)
input()
for i in range(3):
	(a, b, c) = input().split(' ')
	p[0][2].append(a)
	p[1][2].append(b)
	p[2][2].append(c)
(x, y) = map(int, input().split())

def okr(a):
	d = a // 3
	if a % 3 > 0:
		d += 1
	return d
x -= 1
y -= 1
xm = x // 3
ym = y // 3
xg = x - xm * 3
yg = y - ym * 3
s = ''
s += p[yg][xg][0]
s += p[yg][xg][1]
s += p[yg][xg][2]
if '.' in s:
	for i in range(3):
		z = ''
		for j in p[yg][xg][i]:
			if j == '.':
				z += '!'
			else:
				z += j
		p[yg][xg][i] = z
else:
	for yn in range(3):
		for xn in range(3):
			for i in range(3):
				z = ''
				for j in p[yn][xn][i]:
					if j == '.':
						z += '!'
					else:
						z += j
				p[yn][xn][i] = z
for i in range(3):
	print(p[0][0][i], ' ', p[1][0][i], ' ', p[2][0][i])
print()
for i in range(3):
	print(p[0][1][i], ' ', p[1][1][i], ' ', p[2][1][i])
print()
for i in range(3):
	print(p[0][2][i], ' ', p[1][2][i], ' ', p[2][2][i])
print()


from collections import *
import os, sys
from io import BytesIO, IOBase

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
BUFSIZE = 8192
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
rstr = lambda : input().strip()
rstrs = lambda : [list(str(x)) for x in input().split()]
rstr_2d = lambda n: [rstr() for _ in range(n)]
rstrs_2d = lambda n: [rstrs() for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
grid = rstrs_2d(11)
(x, y) = rints()
grid.remove([])
grid.remove([])
(r1, c1) = (0, 0)
for i in range(3, 10, 3):
	if i - 3 < x <= i:
		r1 = i - 2
	if i - 3 < y <= i:
		c1 = i - 2
(r, c, flag) = ((x - r1) * 3, y - c1, 0)
for i in range(r, r + 3):
	for j in range(3):
		if grid[i][c][j] == '.':
			(grid[i][c][j], flag) = ('!', 1)
if not flag:
	for i in range(9):
		for j in range(3):
			for k in range(3):
				if grid[i][j][k] == '.':
					grid[i][j][k] = '!'
for i in range(9):
	for j in range(3):
		print(*grid[i][j], sep='', end=' ')
	print()
	if (i + 1) % 3 == 0:
		print()


R = input
g = [list(R()) for _ in range(11)]
(r, c) = map(int, R().split())
(r, c) = ((r - 1) % 3 * 4, (c - 1) % 3 * 4)
(f, d) = '.!'
for i in range(9):
	(s, e) = (g[r + i // 3], c + i % 3)
	if s[e] < 'o':
		s[e] = f = d
for v in g:
	print(''.join(v).replace(f, d))


field = []
rows = 0
while len(field) < 9:
	input_row = [x for x in input().split()]
	if not input_row:
		continue
	curr_row = []
	for part in input_row:
		for elem in part:
			curr_row.append(elem)
	field.append(curr_row)
(row, col) = (int(x) for x in input().split())
row -= 1
col -= 1
glob_row = row // 3
glob_col = col // 3
next_glob_row = row - 3 * glob_row
next_glob_col = col - 3 * glob_col
flag = True
for r in range(3):
	curr_row = next_glob_row * 3 + r
	for c in range(3):
		curr_col = next_glob_col * 3 + c
		if field[curr_row][curr_col] == '.':
			field[curr_row][curr_col] = '!'
			flag = False
for r in range(9):
	for c in range(9):
		if flag and field[r][c] == '.':
			field[r][c] = '!'
		print(field[r][c], end='')
		if c in [2, 5]:
			print(' ', end='')
	print('')
	if r in [2, 5]:
		print('')


a = [None] * 11
for i in range(11):
	a[i] = list(input())
(x, y) = map(int, input().split())
x = (3 if x % 3 == 0 else x % 3) * 4 - 3
y = (3 if y % 3 == 0 else y % 3) * 4 - 3
row_1 = a[x - 1][y - 1:y + 2]
row_2 = a[x][y - 1:y + 2]
row_3 = a[x + 1][y - 1:y + 2]
if '.' in row_1 + row_2 + row_3:
	a[x - 1][y - 1:y + 2] = ''.join(row_1).replace('.', '!')
	a[x][y - 1:y + 2] = ''.join(row_2).replace('.', '!')
	a[x + 1][y - 1:y + 2] = ''.join(row_3).replace('.', '!')
	for i in range(11):
		a[i] = ''.join(a[i])
else:
	for i in range(11):
		a[i] = ''.join(a[i]).replace('.', '!')
print('\n'.join(a))


field = []
for j in range(0, 11):
	row_str = input()
	if len(row_str):
		row = []
		for i in range(0, 11):
			if row_str[i] in ['.', 'x', 'o']:
				row.append(row_str[i])
		field.append(row)
(x, y) = map(int, input().split())
X = (x - 1) % 3
Y = (y - 1) % 3
filled = False
for i in range(X * 3, X * 3 + 3):
	for j in range(Y * 3, Y * 3 + 3):
		if field[i][j] == '.':
			field[i][j] = '!'
			filled = True
if not filled:
	for i in range(0, 9):
		for j in range(0, 9):
			if field[i][j] == '.':
				field[i][j] = '!'
for i in range(0, 9):
	for j in range(0, 9):
		print(field[i][j], end='')
		if (j + 1) % 3 == 0:
			print(' ', end='')
	print('')
	if (i + 1) % 3 == 0:
		print('')


l = []
for i in range(11):
	l.append(list(input()))
(x, y) = [int(i) for i in input().split()]
if x <= 3:
	x -= 1
if y <= 3:
	y -= 1
if x >= 7:
	x += 1
if y >= 7:
	y += 1
status = True
if x % 4 == 0:
	if y % 4 == 0:
		for i in range(3):
			for j in range(3):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
	elif y % 4 == 1:
		for i in range(3):
			for j in range(4, 7):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
	else:
		for i in range(3):
			for j in range(8, 11):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
elif x % 4 == 1:
	if y % 4 == 0:
		for i in range(4, 7):
			for j in range(3):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
	elif y % 4 == 1:
		for i in range(4, 7):
			for j in range(4, 7):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
	else:
		for i in range(4, 7):
			for j in range(8, 11):
				if l[i][j] == '.':
					l[i][j] = '!'
					status = False
elif y % 4 == 0:
	for i in range(8, 11):
		for j in range(3):
			if l[i][j] == '.':
				l[i][j] = '!'
				status = False
elif y % 4 == 1:
	for i in range(8, 11):
		for j in range(4, 7):
			if l[i][j] == '.':
				l[i][j] = '!'
				status = False
else:
	for i in range(8, 11):
		for j in range(8, 11):
			if l[i][j] == '.':
				l[i][j] = '!'
				status = False
if status:
	for w in l:
		for i in range(len(w)):
			if w[i] == '.':
				w[i] = '!'
for w in l:
	print(''.join(w))


d = []
for i in range(11):
	s = input()
	if i != 3 and i != 7:
		d.append(s)
(x, y) = map(int, input().split())
x -= 1
y -= 1
row = x % 3
if row == 1:
	row = 3
if row == 2:
	row = 6
col = y % 3
if col == 1:
	col = 4
if col == 2:
	col = 8
flag = False
for i in range(row, row + 3):
	for j in range(col, col + 3):
		if d[i][j] == '.':
			flag = True
if flag:
	for i in range(row, row + 3):
		for j in range(col, col + 3):
			if d[i][j] == '.':
				d[i] = d[i][:j] + '!' + d[i][j + 1:]
else:
	for i in range(len(d)):
		for j in range(len(d[i])):
			if d[i][j] == '.':
				d[i] = d[i][:j] + '!' + d[i][j + 1:]
for i in range(3):
	print(d[i])
print('')
for i in range(3, 6):
	print(d[i])
print('')
for i in range(6, 9):
	print(d[i])


import bisect

def list_output(s):
	print(' '.join(map(str, s)))

def list_input(s='int'):
	if s == 'int':
		return list(map(int, input().split()))
	elif s == 'float':
		return list(map(float, input().split()))
	return list(map(str, input().split()))
M = list()
for i in range(11):
	M.append(list(input()))
(r, c) = map(int, input().split())
r -= 1
c -= 1
r %= 3
c %= 3
cnt = 0
for i in range(3 * r, 3 * r + 3):
	for j in range(3 * c, 3 * c + 3):
		(di, dj) = (0, 0)
		if i >= 6:
			di = 2
		elif i >= 3:
			di = 1
		if j >= 6:
			dj = 2
		elif j >= 3:
			dj = 1
		if M[i + di][j + dj] == '.':
			M[i + di][j + dj] = '!'
			cnt += 1
if cnt == 0:
	for i in range(0, 11):
		for j in range(0, len(M[i])):
			if M[i][j] == '.':
				M[i][j] = '!'
for i in range(11):
	print(''.join(map(str, M[i])))


field = [[''] * 9 for i in range(9)]
z = 0
for i in range(3):
	temp2 = input()
	for z2 in range(len(temp2)):
		if temp2[z2] != ' ':
			field[i][z] = temp2[z2]
			z += 1
	z = 0
input()
for i in range(3, 6):
	temp2 = input()
	for z2 in range(len(temp2)):
		if temp2[z2] != ' ':
			field[i][z] = temp2[z2]
			z += 1
	z = 0
input()
for i in range(6, 9):
	temp2 = input()
	for z2 in range(len(temp2)):
		if temp2[z2] != ' ':
			field[i][z] = temp2[z2]
			z += 1
	z = 0
(x, y) = map(int, input().split())
x2 = (y - 1) % 3 * 3
y2 = (x - 1) % 3 * 3
temp = 0
for i in range(3):
	for j in range(3):
		if field[y2 + i][x2 + j] == '.':
			field[y2 + i][x2 + j] = '!'
			temp += 1
if temp == 0:
	for i in range(9):
		for j in range(9):
			if field[i][j] == '.':
				field[i][j] = '!'
for i in range(9):
	for j in range(9):
		if j % 3 == 0 and j != 0:
			print('', end=' ')
		print(field[i][j], end='')
	if i % 3 == 2 and i != 8:
		print()
	print()


import itertools
import bisect
import collections
import math
import sys
from collections import *
import os
import sys
from io import BytesIO, IOBase
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

def main():
	lst = []
	for i in range(11):
		lst.append(li())
	(x, y) = mii()
	(s1, s2, s3, s4, s5, s6, s7, s8, s9) = ('', '', '', '', '', '', '', '', '')
	for i in range(len(lst)):
		for j in range(len(lst[i])):
			if i <= 2 and j <= 2:
				s1 += lst[i][j]
			if 4 <= i <= 6 and j <= 2:
				s4 += lst[i][j]
			if 8 <= i <= 10 and j <= 2:
				s7 += lst[i][j]
			if i <= 2 and 4 <= j <= 6:
				s2 += lst[i][j]
			if 4 <= i <= 6 and 4 <= j <= 6:
				s5 += lst[i][j]
			if 8 <= i <= 10 and 4 <= j <= 6:
				s8 += lst[i][j]
			if i <= 2 and 8 <= j <= 10:
				s3 += lst[i][j]
			if 4 <= i <= 6 and 8 <= j <= 10:
				s6 += lst[i][j]
			if 8 <= i <= 10 and 8 <= j <= 10:
				s9 += lst[i][j]
	if x >= 1 and (x - 1) % 3 == 0 and (y >= 1) and ((y - 1) % 3 == 0):
		if s1.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if i <= 2 and j <= 2 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif x >= 1 and (x - 1) % 3 == 0 and (y >= 2) and ((y - 2) % 3 == 0):
		if s2.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if i <= 2 and 4 <= j <= 6 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif x >= 1 and (x - 1) % 3 == 0 and (y % 3 == 0):
		if s3.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if i <= 2 and 8 <= j <= 10 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif x >= 2 and (x - 2) % 3 == 0 and (y >= 1) and ((y - 1) % 3 == 0):
		if s4.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if 4 <= i <= 6 and j <= 2 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif x >= 2 and (x - 2) % 3 == 0 and (y >= 2) and ((y - 2) % 3 == 0):
		if s5.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if 4 <= i <= 6 and 4 <= j <= 6 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif x >= 2 and (x - 2) % 3 == 0 and ((y - 0) % 3 == 0):
		if s6.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if 4 <= i <= 6 and 8 <= j <= 10 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif (x - 0) % 3 == 0 and y >= 1 and ((y - 1) % 3 == 0):
		if s7.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if 8 <= i <= 10 and j <= 2 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif (x - 0) % 3 == 0 and y >= 2 and ((y - 2) % 3 == 0):
		if s8.count('.'):
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if 8 <= i <= 10 and 4 <= j <= 6 and (lst[i][j] == '.'):
						lst[i][j] = '!'
		else:
			for i in range(len(lst)):
				for j in range(len(lst[i])):
					if lst[i][j] == '.':
						lst[i][j] = '!'
	elif s9.count('.'):
		for i in range(len(lst)):
			for j in range(len(lst[i])):
				if 8 <= i <= 10 and 8 <= j <= 10 and (lst[i][j] == '.'):
					lst[i][j] = '!'
	else:
		for i in range(len(lst)):
			for j in range(len(lst[i])):
				if lst[i][j] == '.':
					lst[i][j] = '!'
	for i in range(len(lst)):
		print(''.join(lst[i]))
	return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = []
for j in range(11):
	b = input().split()
	if b == []:
		continue
	else:
		a.append([i for i in b[0] + b[1] + b[2]])
(x, y) = [int(i) for i in input().split()]
chk = [2, 0, 1]
x = chk[x % 3]
y = chk[y % 3]
cnt = 0
for i in range(x * 3, x * 3 + 3):
	for j in range(y * 3, y * 3 + 3):
		if a[i][j] == '.':
			a[i][j] = '!'
			cnt = 1
if cnt == 0:
	for i in range(9):
		for j in range(9):
			if a[i][j] == '.':
				a[i][j] = '!'
for i in range(9):
	if i != 0 and i % 3 == 0:
		print()
	for j in range(3):
		print(''.join(a[i][j * 3:j * 3 + 3]), end=' ')
	print()


a = []
for i in range(11):
	f = input()
	if i != 3 and i != 7:
		a.append(f[:3] + f[4:7] + f[8:])
(x, y) = map(int, input().split())
x1 = x % 3
y1 = y % 3
if x1 == 0:
	x1 = 3
if y1 == 0:
	y1 = 3
bl = False
for i in range(3 * (x1 - 1), 3 * x1):
	for j in range(3 * (y1 - 1), 3 * y1):
		if a[i][j] == '.':
			bl = True
			a[i] = a[i][:j] + '!' + a[i][j + 1:]
if bl:
	for i in range(9):
		s = ''
		for j in range(9):
			if j % 3 == 0 and j != 0:
				s += ' '
			s += a[i][j]
		if i % 3 == 0 and i != 0:
			print()
		print(s)
else:
	for i in range(9):
		s = ''
		for j in range(9):
			if j % 3 == 0 and j != 0:
				s += ' '
			if a[i][j] == '.':
				s += '!'
			else:
				s += a[i][j]
		if i % 3 == 0 and i != 0:
			print()
		print(s)


def main():
	arr = []
	for i in range(11):
		if i == 3 or i == 7:
			str(input())
		else:
			arr.append(list(str(input()).replace(' ', '')))
	(x, y) = map(int, input().split())
	xreg = (x - 1) % 3
	yreg = (y - 1) % 3
	flag = True
	cnt = 0
	for i in range(xreg * 3, (xreg + 1) * 3):
		for j in range(yreg * 3, (yreg + 1) * 3):
			if arr[i][j] != '.':
				cnt += 1
	if cnt == 9:
		flag = False
	if flag:
		for i in range(xreg * 3, (xreg + 1) * 3):
			for j in range(yreg * 3, (yreg + 1) * 3):
				if arr[i][j] == '.':
					arr[i][j] = '!'
	else:
		for i in range(len(arr)):
			for j in range(len(arr[i])):
				if arr[i][j] == '.':
					arr[i][j] = '!'
	for i in range(9):
		if i == 3 or i == 6:
			print()
		for j in range(3):
			string = ''.join(arr[i][j * 3:(j + 1) * 3])
			print(string, end=' ')
		print()
main()


l = [[[] for i in range(3)] for i in range(3)]
for i in range(3):
	for j in range(3):
		tmp = list(map(str, input().split(' ')))
		for k in range(3):
			l[k][i] += [tmp[k]]
	if i != 2:
		input()
(y, x) = list(map(int, input().split(' ')))
y = y - 1
x = x - 1
yy = y % 3
xx = x % 3
f = 0
for i in range(3):
	s = list(l[xx][yy][i])
	for j in range(3):
		if s[j] == '.':
			s[j] = '!'
			f = 1
	l[xx][yy][i] = ''.join(s)
if f == 0:
	for i in range(3):
		for j in range(3):
			for k in range(3):
				s = list(l[i][j][k])
				for z in range(3):
					if s[z] == '.':
						s[z] = '!'
				l[i][j][k] = ''.join(s)
for i in range(3):
	for j in range(3):
		print(l[0][i][j], l[1][i][j], l[2][i][j])
	print()


l = []
for _ in range(11):
	s = input().replace(' ', '')
	if len(s):
		l.append(list(s))
(x, y) = map(int, input().split())
x -= 1
y -= 1
x %= 3
y %= 3
ok = False
for i in range(x * 3, x * 3 + 3):
	for j in range(y * 3, y * 3 + 3):
		if l[i][j] == '.':
			ok = True
			l[i][j] = '!'
if not ok:
	for i in range(9):
		for j in range(9):
			if l[i][j] == '.':
				l[i][j] = '!'
for i in range(9):
	for j in range(9):
		print(l[i][j], end='')
		if j % 3 == 2:
			print(' ', end='')
	print()
	if i % 3 == 2:
		print()


B = [list() for i in range(9)]
for i in range(0, 9, 3):
	for j in range(3):
		(a, b, c) = map(list, input().split())
		B[i].append(a)
		B[i + 1].append(b)
		B[i + 2].append(c)
	k = input()
(x, y) = map(int, k.split())
(X, Y) = ((x - 1) % 3, (y - 1) % 3)
X *= 3
f = 0
for i in range(3):
	for j in range(3):
		if B[X + Y][i][j] == '.':
			B[X + Y][i][j] = '!'
			f = 1
if f == 0:
	for t in range(3):
		X = t * 3
		for Y in range(3):
			for i in range(3):
				for j in range(3):
					if B[X + Y][i][j] == '.':
						B[X + Y][i][j] = '!'
for X in range(0, 9, 3):
	for i in range(3):
		print(' '.join([''.join(B[X][i]), ''.join(B[X + 1][i]), ''.join(B[X + 2][i])]))
	print()


a = [0] * 9
j = 0
for i in range(11):
	if i == 3 or i == 7:
		w = input()
		continue
	a[j] = list(''.join(input().split()))
	j += 1
(x, y) = map(int, input().split())
x -= 1
y -= 1
x %= 3
y %= 3
if x == 1:
	x = 3
elif x == 2:
	x = 6
if y == 1:
	y = 3
elif y == 2:
	y = 6
flag = True
for i in range(x, x + 3):
	for j in range(y, y + 3):
		if a[i][j] == '.':
			flag = False
			a[i][j] = '!'
for i in range(9):
	if i % 3 == 0 and i != 0:
		print('')
	for j in range(9):
		if j % 3 == 0 and j != 0:
			print(' ', end='')
		if flag and a[i][j] == '.':
			print('!', end='')
		else:
			print(a[i][j], end='')
	print('')


l = [input() for _ in range(11)]
(x, y) = map(int, input().split())
(a, b) = ((x - 1) % 3 * 4, (y - 1) % 3 * 4)
f = 0
for i in range(a, a + 3):
	s = l[i][b:b + 3]
	if '.' in s:
		(l[i], f) = (l[i][:b] + s.replace('.', '!') + l[i][b + 3:], 1)
for s in l:
	print(s if f else s.replace('.', '!'))


array = []
t = []
m = []
l = []
top = [0, 3]
mid = [3, 6]
down = [6, 9]
dic = {'tt': [1, 1], 'tm': [1, 2], 'td': [1, 0], 'mt': [2, 1], 'mm': [2, 2], 'md': [2, 0], 'dt': [0, 1], 'dm': [0, 2], 'dd': [0, 0]}
dic2 = {'t': [0, 3], 'm': [3, 6], 'd': [6, 9]}
for run in range(2):
	for _ in range(3):
		next = input().split()
		arr = [list(x) for x in next]
		temp = []
		for i in range(3):
			temp = temp + arr[i]
		array.append(temp[:])
	input()
for _ in range(3):
	next = input().split()
	arr = [list(x) for x in next]
	temp = []
	for i in range(3):
		temp = temp + arr[i]
	array.append(temp[:])
(a, b) = map(lambda x: int(x) % 3, input().split())
position = ''
for (k, v) in dic.items():
	if a == v[0] and b == v[1]:
		position = k
		break
loop1 = dic2.get(position[0])
loop2 = dic2.get(position[1])
check = 1
for i in range(loop1[0], loop1[1]):
	for j in range(loop2[0], loop2[1]):
		if array[i][j] == '.':
			check = 0
			array[i][j] = '!'
if check:
	for i in range(9):
		for j in range(9):
			if array[i][j] == '.':
				array[i][j] = '!'
for i in range(9):
	print(''.join(array[i][0:3]), ''.join(array[i][3:6]), ''.join(array[i][6:9]))
	if (i + 1) % 3 == 0:
		print('')


a = []
for i in range(9):
	a.append(list(input().split()))
	a[i] = [a[i][0][0], a[i][0][1], a[i][0][2], a[i][1][0], a[i][1][1], a[i][1][2], a[i][2][0], a[i][2][1], a[i][2][2]]
	if i % 3 == 2 and i != 8:
		input()
(x, y) = map(int, input().split())
posx = 0
posy = 0
if x % 3 == 0:
	posx = 2
	if y % 3 == 0:
		posy = 2
	elif y % 3 == 1:
		posy = 0
	else:
		posy = 1
elif x % 3 == 1:
	posx = 0
	if y % 3 == 0:
		posy = 2
	elif y % 3 == 1:
		posy = 0
	else:
		posy = 1
else:
	posx = 1
	if y % 3 == 0:
		posy = 2
	elif y % 3 == 1:
		posy = 0
	else:
		posy = 1
flag = True
for i in range(3):
	for j in range(3):
		if a[3 * posx + i][3 * posy + j] == '.':
			flag = False
			a[3 * posx + i][3 * posy + j] = '!'
if flag:
	for i in range(9):
		for j in range(9):
			if a[i][j] == '.':
				a[i][j] = '!'
for i in range(9):
	for j in range(9):
		print(a[i][j], end='')
		if j % 3 == 2:
			print(' ', end='')
	print()
	if i % 3 == 2:
		print()


l = []
for i in range(11):
	l.append(input())
(x, y) = map(int, input().split())
if x >= 4 and x <= 6:
	x -= 3
elif x >= 7:
	x -= 6
if y >= 4 and y <= 6:
	y -= 3
elif y >= 7:
	y -= 6
if x == 1:
	p = 0
elif x == 2:
	p = 4
elif x == 3:
	p = 8
if y == 1:
	p2 = 0
elif y == 2:
	p2 = 4
elif y == 3:
	p2 = 8
com = 0
for i in range(p, p + 3):
	for j in range(p2, p2 + 3):
		if l[i][j] == '.':
			com += 1
if com == 0:
	for i in (0, 1, 2, 4, 5, 6, 8, 9, 10):
		if i == 4 or i == 8:
			print()
		for j in range(11):
			if l[i][j] == '.':
				print('!', end='')
			else:
				print(l[i][j], end='')
		print()
else:
	for i in (0, 1, 2, 4, 5, 6, 8, 9, 10):
		if i == 4 or i == 8:
			print()
		for j in range(11):
			if i >= p and i < p + 3 and (j >= p2) and (j < p2 + 3):
				if l[i][j] == '.':
					print('!', end='')
				else:
					print(l[i][j], end='')
			else:
				print(l[i][j], end='')
		print()


a = []
for i in range(11):
	if i == 3 or i == 7:
		input()
	else:
		(x, y, z) = map(str, input().split())
		a.append(list(x + y + z))
(x, y) = map(int, input().split())
if x % 3 == 0:
	u = 6
	d = 8
elif x % 3 == 2:
	u = 3
	d = 5
else:
	u = 0
	d = 2
if y % 3 == 0:
	l = 6
	r = 8
elif y % 3 == 2:
	l = 3
	r = 5
else:
	l = 0
	r = 2
empty = False
for i in range(u, d + 1):
	for j in range(l, r + 1):
		if a[i][j] == '.':
			empty = True
			a[i][j] = '!'
if not empty:
	for i in range(9):
		for j in range(9):
			if a[i][j] == '.':
				a[i][j] = '!'
for i in range(9):
	if i == 3 or i == 6:
		print()
	print(''.join(map(str, a[i][0:3])), ''.join(map(str, a[i][3:6])), ''.join(map(str, a[i][6:9])))


field = []
for _ in range(3):
	row = list(input().replace(' ', ''))
	field.append(row)
input()
for _ in range(3):
	row = list(input().replace(' ', ''))
	field.append(row)
input()
for _ in range(3):
	row = list(input().replace(' ', ''))
	field.append(row)
(x, y) = list(map(int, input().split()))
x -= 1
y -= 1
row = x % 3
column = y % 3
is_full = True
for i in range(row * 3, row * 3 + 3):
	for j in range(column * 3, column * 3 + 3):
		if field[i][j] == '.':
			field[i][j] = '!'
			is_full = False
if is_full:
	for i in range(0, 9):
		for j in range(0, 9):
			if field[i][j] == '.':
				field[i][j] = '!'
for i in range(0, 9):
	for j in range(0, 9):
		print(field[i][j], end='')
		if j == 2 or j == 5:
			print(' ', end='')
	print(' ')
	if i == 2 or i == 5:
		print(' ')


from sys import stdin, stdout
b = stdin.readlines()
(x, y) = [int(z) for z in b[-1].strip().split()]
m = [list(l) for l in b[:-1]]
(pos_x, pos_y) = ((x - 1) % 3, (y - 1) % 3)
free = 0
for i in range(4 * pos_x, 4 * pos_x + 3):
	for j in range(4 * pos_y, 4 * pos_y + 3):
		if m[i][j] == '.':
			free += 1
			m[i][j] = '!'
if free == 0:
	for l in m:
		stdout.write(''.join(l).replace('.', '!'))
else:
	for l in m:
		stdout.write(''.join(l))
stdout.write('\n')


d = []
for i in range(11):
	d.append(input())
del d[7]
del d[3]
p = []
for i in d:
	p.append(''.join(i.split(' ')))
(x, y) = map(int, input().split())
X = (x - 1) // 3 + 1
x = (x - 1) % 3
Y = y // 3
y = (y - 1) % 3
f = False
for i in range(3 * x, 3 * x + 3):
	for j in range(3 * y, 3 * y + 3):
		if p[i][j] == '.':
			p[i] = p[i][:j] + '!' + p[i][j + 1:]
			f = True
if not f:
	for i in range(len(p)):
		for j in range(len(p)):
			if p[i][j] == '.':
				p[i] = p[i][:j] + '!' + p[i][j + 1:]
for i in range(3):
	for j in range(3):
		for k in range(3):
			print(p[i * 3 + j][3 * k:3 * k + 3], end=' ')
		print()
	print()


a1 = input()
a2 = input()
a3 = input()
f = input()
b4 = input()
b5 = input()
b6 = input()
g = input()
c7 = input()
c8 = input()
c9 = input()
(x, y) = list(map(int, input().split()))
g = x % 3
h = y % 3
if g == 1:
	if h == 1:
		if '.' in a1[0:3] or '.' in a2[0:3] or '.' in a3[0:3]:
			a1 = a1[0:3].replace('.', '!') + a1[3:]
			a2 = a2[0:3].replace('.', '!') + a2[3:]
			a3 = a3[0:3].replace('.', '!') + a3[3:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 2:
		if '.' in a1[4:7] or '.' in a2[4:7] or '.' in a3[4:7]:
			a1 = a1[:4] + a1[4:7].replace('.', '!') + a1[7:]
			a2 = a2[:4] + a2[4:7].replace('.', '!') + a2[7:]
			a3 = a3[:4] + a3[4:7].replace('.', '!') + a3[7:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 0:
		if '.' in a1[8:11] or '.' in a2[8:11] or '.' in a3[8:11]:
			a1 = a1[:8] + a1[8:11].replace('.', '!')
			a2 = a2[:8] + a2[8:11].replace('.', '!')
			a3 = a3[:8] + a3[8:11].replace('.', '!')
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
elif g == 2:
	if h == 1:
		if '.' in b4[0:3] or '.' in b5[0:3] or '.' in b6[0:3]:
			b4 = b4[0:3].replace('.', '!') + b4[3:]
			b5 = b5[0:3].replace('.', '!') + b5[3:]
			b6 = b6[0:3].replace('.', '!') + b6[3:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 2:
		if '.' in b4[4:7] or '.' in b5[4:7] or '.' in b6[4:7]:
			b4 = b4[:4] + b4[4:7].replace('.', '!') + b4[7:]
			b5 = b5[:4] + b5[4:7].replace('.', '!') + b5[7:]
			b6 = b6[:4] + b6[4:7].replace('.', '!') + b6[7:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 0:
		if '.' in b4[8:11] or '.' in b5[8:11] or '.' in b6[8:11]:
			b4 = b4[:8] + b4[8:11].replace('.', '!')
			b5 = b5[:8] + b5[8:11].replace('.', '!')
			b6 = b6[:8] + b6[8:11].replace('.', '!')
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
elif g == 0:
	if h == 1:
		if '.' in c7[0:3] or '.' in c8[0:3] or '.' in c9[0:3]:
			c7 = c7[0:3].replace('.', '!') + c7[3:]
			c8 = c8[0:3].replace('.', '!') + c8[3:]
			c9 = c9[0:3].replace('.', '!') + c9[3:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 2:
		if '.' in c7[4:7] or '.' in c8[4:7] or '.' in c9[4:7]:
			c7 = c7[:4] + c7[4:7].replace('.', '!') + c7[7:]
			c8 = c8[:4] + c8[4:7].replace('.', '!') + c8[7:]
			c9 = c9[:4] + c9[4:7].replace('.', '!') + c9[7:]
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
	if h == 0:
		if '.' in c7[8:11] or '.' in c8[8:11] or '.' in c9[8:11]:
			c7 = c7[:8] + c7[8:11].replace('.', '!')
			c8 = c8[:8] + c8[8:11].replace('.', '!')
			c9 = c9[:8] + c9[8:11].replace('.', '!')
		else:
			a1 = a1.replace('.', '!')
			a2 = a2.replace('.', '!')
			a3 = a3.replace('.', '!')
			b4 = b4.replace('.', '!')
			b5 = b5.replace('.', '!')
			b6 = b6.replace('.', '!')
			c7 = c7.replace('.', '!')
			c8 = c8.replace('.', '!')
			c9 = c9.replace('.', '!')
print(a1)
print(a2)
print(a3)
print()
print(b4)
print(b5)
print(b6)
print()
print(c7)
print(c8)
print(c9)


m = []
for i in range(11):
	s = input().split()
	if i == 3 or i == 7:
		continue
	m += [s]
matrix = []
for i in m:
	cur = ''
	for j in i:
		cur += j
	matrix.append(cur)
for i in range(9):
	matrix[i] = list(matrix[i])
(x, y) = map(int, input().split())
x -= 1
y -= 1
field = [x % 3, y % 3]
cnt = 0
for i in range(field[0] * 3, field[0] * 3 + 3):
	for j in range(field[1] * 3, field[1] * 3 + 3):
		cnt += matrix[i][j] == '.'
if cnt == 0:
	for i in range(9):
		for j in range(9):
			if matrix[i][j] == '.':
				matrix[i][j] = '!'
else:
	for i in range(field[0] * 3, field[0] * 3 + 3):
		for j in range(field[1] * 3, field[1] * 3 + 3):
			if matrix[i][j] == '.':
				matrix[i][j] = '!'
for i in range(9):
	for j in range(9):
		if j == 2 or j == 5:
			print(matrix[i][j], end=' ')
		else:
			print(matrix[i][j], end='')
	print()
	if i == 2 or i == 5:
		print()


grid = []
for i in range(3):
	inp = input()
	inp = inp[:3] + inp[4:7] + inp[8:]
	grid.append(inp)
inp = input()
for i in range(3):
	inp = input()
	inp = inp[:3] + inp[4:7] + inp[8:]
	grid.append(inp)
inp = input()
for i in range(3):
	inp = input()
	inp = inp[:3] + inp[4:7] + inp[8:]
	grid.append(inp)
inp = input().split(' ')
x = int(inp[0])
y = int(inp[1])
xn = x % 3
yn = y % 3
xn -= 1
yn -= 1
if xn < 0:
	xn += 3
if yn < 0:
	yn += 3
check = False
for i in range(3):
	for j in range(3):
		if grid[3 * xn + i][3 * yn + j] == '.':
			check = True
			break
	if check:
		break
if check:
	for i in range(3):
		for j in range(3):
			if grid[3 * xn + i][3 * yn + j] == '.':
				grid[3 * xn + i] = list(grid[3 * xn + i])
				grid[3 * xn + i][3 * yn + j] = '!'
				grid[3 * xn + i] = ''.join(grid[3 * xn + i])
else:
	for i in range(9):
		for j in range(9):
			if i < 3 * xn + 3 and i >= xn * 3 and (j >= yn * 3) and (j < 3 * yn + 3):
				continue
			elif grid[i][j] != '.':
				continue
			else:
				grid[i] = list(grid[i])
				grid[i][j] = '!'
				grid[i] = ''.join(grid[i])
for i in range(9):
	if i % 3 == 0 and i != 0:
		print()
	print(grid[i][:3] + ' ' + grid[i][3:6] + ' ' + grid[i][6:])


s = []
for _ in range(11):
	s.append(input())
(r, c) = map(int, input().split())
pos = False
sr = (r % 3 * 4 - 4) % 12
sc = (c % 3 * 4 - 4) % 12
for i in range(3):
	for j in range(3):
		if s[sr + i][sc + j] == '.':
			pos = True
			s[sr + i] = s[sr + i][:sc + j] + '!' + s[sr + i][sc + j + 1:]
if pos:
	print('\n'.join(s))
else:
	for i in range(11):
		if i % 4 == 3:
			continue
		for j in range(11):
			if s[i][j] == '.':
				s[i] = s[i][:j] + '!' + s[i][j + 1:]
	print('\n'.join(s))


class field:

	def __init__(self):
		self.cells = []
		for i in range(3):
			self.cells.append([])
			for j in range(3):
				self.cells[i].append('.')

	def __str__(self):
		str = ''
		for i in range(3):
			for j in range(3):
				str += self.cells[i][j]
			if i < 2:
				str += '\n'
		return str

	def exclaim(self):
		changed = False
		for i in range(3):
			for j in range(3):
				if self.cells[i][j] == '.':
					self.cells[i][j] = '!'
					changed = True
		return changed

class board:

	def __init__(self):
		self.fields = []
		for i in range(3):
			self.fields.append([])
			for j in range(3):
				self.fields[i].append(field())

	def __str__(self):
		str = ''
		for i in range(3):
			for j in range(3):
				for k in range(3):
					for l in range(3):
						str += self.fields[i][k].cells[j][l]
					str += ' '
				str += '\n'
			if i < 2:
				str += '\n'
		return str
my_board = board()
row = 0
crow = 0
for i in range(11):
	stdin = input()
	if stdin:
		stdin = stdin.strip().split()
		for j in range(3):
			for k in range(3):
				my_board.fields[row][j].cells[crow][k] = stdin[j][k]
		crow += 1
	else:
		crow = 0
		row += 1
(row, col) = [(int(i) - 1) % 3 for i in input().split()]
if not my_board.fields[row][col].exclaim():
	for i in range(3):
		for j in range(3):
			my_board.fields[i][j].exclaim()
print(my_board)


l = []
for i in range(11):
	s = input()
	s = s.replace(' ', '')
	if i != 3 and i != 7:
		l.append(s)
(y, x) = map(int, input().split())
x -= 1
y -= 1
t = False
for i in range(y % 3 * 3, y % 3 * 3 + 3):
	for j in range(x % 3 * 3, x % 3 * 3 + 3):
		if l[i][j] == '.':
			t = True
			break
	if t:
		break
else:
	for i in range(9):
		for j in range(9):
			if l[i][j] == '.':
				print('!', end='')
			else:
				print(l[i][j], end='')
			if j % 3 == 2:
				print(end=' ')
		print()
		if i % 3 == 2:
			print()
if t:
	for i in range(9):
		for j in range(9):
			if l[i][j] == '.' and y % 3 * 3 <= i <= y % 3 * 3 + 2 and (x % 3 * 3 <= j <= x % 3 * 3 + 2):
				print('!', end='')
			else:
				print(l[i][j], end='')
			if j % 3 == 2:
				print(end=' ')
		print()
		if i % 3 == 2:
			print()


from sys import stdin, stdout
maps = []
sze = 9
for i in range(1, 10):
	maps.append(list(''.join(stdin.readline().strip().split())))
	if not i % 3 and i != 9:
		stdin.readline()
(s, c) = map(int, stdin.readline().split())
c -= 1
s -= 1
c %= 3
s %= 3
acc = c * 3
ass = s * 3
label = 0
for i in range(ass, ass + 3):
	for j in range(acc, acc + 3):
		if maps[i][j] == '.':
			maps[i][j] = '!'
			label = 1
if not label:
	for i in range(len(maps)):
		for j in range(len(maps[i])):
			if maps[i][j] == '.':
				maps[i][j] = '!'
ind = 1
for i in range(len(maps)):
	for j in range(len(maps[i])):
		stdout.write(maps[i][j])
		if not ind % 9:
			stdout.write('\n')
		elif not ind % 3:
			stdout.write(' ')
		ind += 1
	if not (i + 1) % 3:
		stdout.write('\n')


a = []
for i in range(11):
	b = input()
	a.append(b)
(r, c) = [int(x) for x in input().split()]
j = 4 * ((r - 1) % 3)
i = 4 * ((c - 1) % 3)
ans = False
for c0 in range(3):
	for r0 in range(3):
		if a[j + r0][i + c0] == '.':
			ans = True
			break
if ans:
	for r0 in range(11):
		if r0 == 3 or r0 == 7:
			print()
			continue
		for c0 in range(11):
			if c0 >= i and c0 <= i + 2 and (r0 >= j) and (r0 <= j + 2) and (a[r0][c0] == '.'):
				print('!', end='')
			else:
				print(a[r0][c0], end='')
		print()
else:
	for r0 in range(11):
		if r0 == 3 or r0 == 7:
			print()
			continue
		for c0 in range(11):
			if a[r0][c0] == '.':
				print('!', end='')
			else:
				print(a[r0][c0], end='')
		print()


fild = []
first = input().split()
secend = input().split()
third = input().split()
input()
fourth = input().split()
fivth = input().split()
sixth = input().split()
input()
seventh = input().split()
eight = input().split()
ninght = input().split()
(x, y) = list(map(int, input().split()))
fild.append(first[0] + secend[0] + third[0])
fild.append(first[1] + secend[1] + third[1])
fild.append(first[2] + secend[2] + third[2])
fild.append(fourth[0] + fivth[0] + sixth[0])
fild.append(fourth[1] + fivth[1] + sixth[1])
fild.append(fourth[2] + fivth[2] + sixth[2])
fild.append(seventh[0] + eight[0] + ninght[0])
fild.append(seventh[1] + eight[1] + ninght[1])
fild.append(seventh[2] + eight[2] + ninght[2])

def where(x, y):
	if x < 4 and y < 4:
		return int(3 * x - (3 - y))
	elif x < 4 and y < 7:
		return int(3 * x - (3 - (y - 3)))
	elif x < 4:
		return int(3 * x - (3 - (y - 6)))
	elif x < 7 and y < 4:
		return int(3 * (x - 3) - (3 - y))
	elif x < 7 and y < 7:
		return int(3 * (x - 3) - (3 - (y - 3)))
	elif x < 7:
		return int(3 * (x - 3) - (3 - (y - 6)))
	elif y < 4:
		return int(3 * (x - 6) - (3 - y))
	elif y < 7:
		return int(3 * (x - 6) - (3 - (y - 3)))
	else:
		return int(3 * (x - 6) - (3 - (y - 6)))

def swap(a):
	out = ''
	for i in a:
		if i == '.':
			out += '!'
		else:
			out += i
	return out
y_fild = where(x, y) - 1
if fild[y_fild].count('.') != 0:
	fild[y_fild] = swap(fild[y_fild])
else:
	for j in range(9):
		fild[j] = swap(fild[j])
print(fild[0][0:3] + ' ' + fild[1][0:3] + ' ' + fild[2][0:3])
print(fild[0][3:6] + ' ' + fild[1][3:6] + ' ' + fild[2][3:6])
print(fild[0][6:9] + ' ' + fild[1][6:9] + ' ' + fild[2][6:9])
print('')
print(fild[3][0:3] + ' ' + fild[4][0:3] + ' ' + fild[5][0:3])
print(fild[3][3:6] + ' ' + fild[4][3:6] + ' ' + fild[5][3:6])
print(fild[3][6:9] + ' ' + fild[4][6:9] + ' ' + fild[5][6:9])
print('')
print(fild[6][0:3] + ' ' + fild[7][0:3] + ' ' + fild[8][0:3])
print(fild[6][3:6] + ' ' + fild[7][3:6] + ' ' + fild[8][3:6])
print(fild[6][6:9] + ' ' + fild[7][6:9] + ' ' + fild[8][6:9])


def get3x3():
	return [[0 for _ in range(3)] for _ in range(3)]
mats = [[get3x3() for __ in range(3)] for _ in range(3)]
for i in range(11):
	lines = input().split()
	if i == 3 or i == 7:
		continue
	cnt = i
	if i > 3:
		cnt -= 1
	if i > 7:
		cnt -= 1
	for j in range(3):
		mats[cnt // 3][j][cnt % 3] = list(lines[j])
(x0, y0) = map(int, input().split())
x0 -= 1
y0 -= 1
cx = x0 % 3
cy = y0 % 3

def check(cx, cy):
	for i in range(3):
		for j in range(3):
			if mats[cx][cy][i][j] == '.':
				return True
	return False

def mark(cx, cy):
	for i in range(3):
		for j in range(3):
			if mats[cx][cy][i][j] == '.':
				mats[cx][cy][i][j] = '!'
if check(cx, cy):
	mark(cx, cy)
else:
	for tx in range(3):
		for ty in range(3):
			mark(tx, ty)
for i in range(11):
	if i == 3 or i == 7:
		print()
		continue
	cnt = i
	if i > 3:
		cnt -= 1
	if i > 7:
		cnt -= 1
	for j in range(3):
		print(''.join(mats[cnt // 3][j][cnt % 3]), end='')
		if j < 3:
			print(end=' ')
	print()


def print_pole():
	s = ''
	for i in range(1, 10):
		sti = []
		for j in range(3):
			sti.append(''.join(pole[i][j]))
		s += ' '.join(sti) + '\n'
		if i == 3 or i == 6:
			s += '\n'
	print(s)
st = ''
for i in range(11):
	st += input() + ' '
(ylast, xlast) = map(int, input().split())
pole = [0]
pole = [0] * 10
L = st.split()
k = 0
for i in range(1, 10):
	Li = []
	for j in range(3):
		Lij = list(L[k])
		k += 1
		Li.append(Lij)
	pole[i] = Li

def x0(x):
	if x % 3:
		return x % 3 - 1
	else:
		return 2

def y0(y):
	if y % 3:
		return 1 + (y % 3 - 1) * 3
	else:
		return 7
(yl, xl) = (y0(ylast), x0(xlast))
free = False
for si in range(3):
	for i in range(3):
		if pole[yl + si][xl][i] == '.':
			pole[yl + si][xl][i] = '!'
			free = True
if not free:
	for si in range(1, 10):
		for j in range(3):
			for k in range(3):
				if pole[si][j][k] == '.':
					pole[si][j][k] = '!'
print_pole()


t = []
for i in range(11):
	a = input().split()
	if i in [3, 7]:
		continue
	t.append(a[0] + a[1] + a[2])
f = []
for i in range(9):
	f.append(['.'] * 9)
(n, m) = map(int, input().split())
n2 = n % 3 - 1
m2 = m % 3 - 1
if n2 < 0:
	n2 += 3
if m2 < 0:
	m2 += 3
fl = True
for i in range(n2 * 3, n2 * 3 + 3):
	for j in range(m2 * 3, m2 * 3 + 3):
		if t[i][j] == '.':
			fl = False
if not fl:
	for i in range(n2 * 3, n2 * 3 + 3):
		for j in range(m2 * 3, m2 * 3 + 3):
			if t[i][j] == '.':
				f[i][j] = '!'
for i in range(9):
	for j in range(9):
		if j % 3 == 0 and j != 0:
			print(' ', end='')
		if f[i][j] == '!':
			print('!', end='')
		elif t[i][j] != '.':
			print(t[i][j], end='')
		elif fl:
			print('!', end='')
		else:
			print('.', end='')
	if (i + 1) % 3 == 0:
		print()
	print()


grid = [[] for _ in range(9)]
for block in range(3):
	for line in range(3):
		linestr = input()
		linestr = iter(linestr)
		gridline = grid[block * 3 + line]
		for vertbl in range(3):
			for col in range(3):
				gridline.append(next(linestr))
			if vertbl < 2:
				next(linestr)
	if block < 2:
		input()
(x, y) = (int(c) for c in input().split())
(x, y) = (x - 1, y - 1)
(blx, bly) = (x % 3, y % 3)

def check():
	for xx in range(blx * 3, blx * 3 + 3):
		for yy in range(bly * 3, bly * 3 + 3):
			if grid[xx][yy] == '.':
				return False
	return True
nope = check()
for block in range(3):
	for line in range(3):
		gridline = grid[block * 3 + line]
		output = ''
		for vertbl in range(3):
			for col in range(3):
				current = gridline[vertbl * 3 + col]
				if current != '.':
					output += current
				elif nope:
					output += '!'
				elif block == blx and vertbl == bly:
					output += '!'
				else:
					output += '.'
			if vertbl < 2:
				output += ' '
		print(output)
	if block < 2:
		print()


field = [None] * 3
for i in range(3):
	if i != 0:
		input()
	field[i] = line = []
	for j in range(3):
		line.append(input().replace(' ', ''))
(x, y) = map(lambda x: (int(x) - 1) % 3, input().split(' '))
free = False
for i in range(3):
	if free:
		break
	for j in range(3):
		if field[x][i][y * 3 + j] == '.':
			free = True
			break
if free:
	p = y * 3
	for i in range(3):
		field[x][i] = field[x][i][:p] + field[x][i][p:p + 3].replace('.', '!') + field[x][i][p + 3:]
else:
	for line in field:
		for i in range(3):
			line[i] = line[i].replace('.', '!')
j = 0
for line in field:
	if j == 0:
		j = 1
	else:
		print()
	for i in range(3):
		s = line[i]
		s = s[:3] + ' ' + s[3:6] + ' ' + s[6:]
		print(s)


X = []
count = 0
while count < 9:
	Y = input()
	Z = [char for char in Y if char != ' ']
	if Z != []:
		X.append(Z)
		count += 1
(x, y) = map(int, input().split())
u = (x - 1) % 3
v = (y - 1) % 3
ok = False
for i in range(3):
	for j in range(3):
		(t, s) = (3 * u + i, 3 * v + j)
		if X[t][s] == '.':
			X[t][s] = '!'
			ok = True
if ok == False:
	for i in range(9):
		for j in range(9):
			if X[i][j] == '.':
				X[i][j] = '!'
cnt = 0
for i in X:
	cnt += 1
	[u1, u2, u3, u4, u5, u6, u7, u8, u9] = i
	print(u1 + u2 + u3 + ' ' + u4 + u5 + u6 + ' ' + u7 + u8 + u9)
	if cnt == 3 or cnt == 6:
		print(' ')


R = input
g = [list(R()) for _ in range(11)]
(r, c) = map(int, R().split())
(r, c) = ((r - 1) % 3 * 4, (c - 1) % 3 * 4)
f = '.'
for i in range(9):
	s = g[r + i // 3]
	if '.' == s[c + i % 3]:
		s[c + i % 3] = f = '!'
print(*(''.join(v).replace(f, '!') for v in g), sep='\n')


dy = 0
dx = 0
ok = 0
v = []
for i in range(11):
	x = list(''.join(input().split()))
	if len(x) > 0:
		v.append(x)
(y, x) = map(int, input().split())
if y % 3 == 1:
	dy = 0
elif y % 3 == 2:
	dy = 3
else:
	dy = 6
if x % 3 == 1:
	dx = 0
elif x % 3 == 2:
	dx = 3
else:
	dx = 6
for i in range(dy, dy + 3):
	for j in range(dx, dx + 3):
		if v[i][j] == '.':
			ok = 1
if ok == 0:
	for i in range(9):
		if i > 0 and i % 3 == 0:
			print()
		for j in range(9):
			if j > 0 and j % 3 == 0:
				print(end=' ')
			if v[i][j] == '.':
				print('!', end='')
			else:
				print(v[i][j], end='')
		print()
	exit(0)
for i in range(dy, dy + 3):
	for j in range(dx, dx + 3):
		if v[i][j] == '.':
			v[i][j] = '!'
for i in range(9):
	if i > 0 and i % 3 == 0:
		print()
	for j in range(9):
		if j > 0 and j % 3 == 0:
			print(end=' ')
		print(v[i][j], end='')
	print()
exit(0)


import collections, math
local = False
if local:
	file = open('inputt.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
fromTos = [(0, 2), (3, 5), (6, 8)]
grid = []
for i in range(0, 9):
	if i % 3 == 0 and i != 0:
		inp()
	row = inp()
	grid.append([])
	for colbig in row.split():
		grid[-1].append([])
		for sign in colbig:
			grid[-1][-1].append(sign)
(x, y) = ints()
x = (x - 1) % 3
y = (y - 1) % 3
foundFree = False
for i in range(x * 3, x * 3 + 3):
	for k in range(0, 3):
		val = grid[i][y][k]
		if val != 'x' and val != 'o':
			foundFree = True
			grid[i][y][k] = '!'
if not foundFree:
	for i in range(0, 9):
		for j in range(0, 3):
			for k in range(0, 3):
				val = grid[i][j][k]
				if val != 'x' and val != 'o':
					grid[i][j][k] = '!'
for i in range(0, 3):
	row = ''
	for j in range(0, 3):
		row += ''.join(grid[i][j])
		if j < 2:
			row += ' '
	print(row)
print('')
for i in range(3, 6):
	row = ''
	for j in range(0, 3):
		row += ''.join(grid[i][j])
		if j < 2:
			row += ' '
	print(row)
print('')
for i in range(6, 9):
	row = ''
	for j in range(0, 3):
		row += ''.join(grid[i][j])
		if j < 2:
			row += ' '
	print(row)
print('')


game = []
for _ in range(11):
	game.append(list(input()))
(corner_y, corner_x) = map(lambda n: 4 * ((int(n) - 1) % 3), input().split())
any_move = True
for y in range(corner_y, corner_y + 3):
	for x in range(corner_x, corner_x + 3):
		if game[y][x] == '.':
			game[y][x] = '!'
			any_move = False
if any_move:
	for l in game:
		for (index, c) in enumerate(l):
			if l[index] == '.':
				l[index] = '!'
for l in game:
	print(''.join(l))


import sys
board = [list(input().replace(' ', '')) for i in range(11)]
del board[7]
del board[3]
(y, x) = map(int, input().split())
y -= 1
x -= 1
flag = True
py = y % 3
px = x % 3
for i in range(3):
	for j in range(3):
		if board[py * 3 + i][px * 3 + j] == '.':
			flag = False
if flag:
	for i in range(9):
		for j in range(9):
			if board[i][j] == '.':
				board[i][j] = '!'
else:
	for i in range(3):
		for j in range(3):
			if board[py * 3 + i][px * 3 + j] == '.':
				board[py * 3 + i][px * 3 + j] = '!'
for i in range(3):
	for j in range(3):
		for k in range(3):
			if k > 0:
				print(' ', end='')
			for l in range(3):
				print(board[3 * i + j][3 * k + l], end='')
		print('')
	if i < 2:
		print('')


(A11, A21, A31) = input().split()
(A12, A22, A32) = input().split()
(A13, A23, A33) = input().split()
A = input()
(A41, A51, A61) = input().split()
(A42, A52, A62) = input().split()
(A43, A53, A63) = input().split()
A = input()
(A71, A81, A91) = input().split()
(A72, A82, A92) = input().split()
(A73, A83, A93) = input().split()
A1 = A11 + A12 + A13
A2 = A21 + A22 + A23
A3 = A31 + A32 + A33
A4 = A41 + A42 + A43
A5 = A51 + A52 + A53
A6 = A61 + A62 + A63
A7 = A71 + A72 + A73
A8 = A81 + A82 + A83
A9 = A91 + A92 + A93
AA = [A1, A2, A3, A4, A5, A6, A7, A8, A9]
(x, y) = map(int, input().split())
if 0 < x < 4:
	A = [1, 2, 3]
elif 3 < x < 7:
	A = [4, 5, 6]
elif 6 < x < 10:
	A = [7, 8, 9]
if 0 < y < 4:
	B = [1, 4, 7]
elif 3 < y < 7:
	B = [2, 5, 8]
elif 6 < y < 10:
	B = [3, 6, 9]
for i in A:
	if i in B:
		C = i
if C == 2:
	x -= 0
	y -= 3
if C == 3:
	x -= 0
	y -= 6
if C == 4:
	x -= 3
	y -= 0
if C == 5:
	x -= 3
	y -= 3
if C == 6:
	x -= 3
	y -= 6
if C == 7:
	x -= 6
	y -= 0
if C == 8:
	x -= 6
	y -= 3
if C == 9:
	x -= 6
	y -= 6
if x == 1:
	A = [1, 2, 3]
elif x == 2:
	A = [4, 5, 6]
elif x == 3:
	A = [7, 8, 9]
if y == 1:
	B = [1, 4, 7]
elif y == 2:
	B = [2, 5, 8]
elif y == 3:
	B = [3, 6, 9]
for i in A:
	if i in B:
		C1 = i
k = 0
V = ['!']
for i in range(len(AA[C1 - 1])):
	if AA[C1 - 1][i] == '.':
		k += 1
		AA[C1 - 1] = AA[C1 - 1][:i] + '!' + AA[C1 - 1][i + 1:]
if k == 0:
	for i in range(0, 9):
		for j in range(len(AA[i])):
			if AA[i][j] == '.':
				AA[i] = AA[i][:j] + '!' + AA[i][j + 1:]
print(''.join(map(str, AA[0][0:3])), ''.join(map(str, AA[1][0:3])), ''.join(map(str, AA[2][0:3])))
print(''.join(map(str, AA[0][3:6])), ''.join(map(str, AA[1][3:6])), ''.join(map(str, AA[2][3:6])))
print(''.join(map(str, AA[0][6:])), ''.join(map(str, AA[1][6:])), ''.join(map(str, AA[2][6:])))
print('')
print(''.join(map(str, AA[3][0:3])), ''.join(map(str, AA[4][0:3])), ''.join(map(str, AA[5][0:3])))
print(''.join(map(str, AA[3][3:6])), ''.join(map(str, AA[4][3:6])), ''.join(map(str, AA[5][3:6])))
print(''.join(map(str, AA[3][6:])), ''.join(map(str, AA[4][6:])), ''.join(map(str, AA[5][6:])))
print('')
print(''.join(map(str, AA[6][0:3])), ''.join(map(str, AA[7][0:3])), ''.join(map(str, AA[8][0:3])))
print(''.join(map(str, AA[6][3:6])), ''.join(map(str, AA[7][3:6])), ''.join(map(str, AA[8][3:6])))
print(''.join(map(str, AA[6][6:])), ''.join(map(str, AA[7][6:])), ''.join(map(str, AA[8][6:])))


badook = []
last = []
for i in range(12):
	k = list(input().strip().split())
	if i != 3 and i != 7 and (i != 11):
		for p in range(len(k)):
			k[p] = list(k[p])
		badook.append(k)
	elif i == 11:
		last = list(map(int, k))
firstindex = (last[0] - 1) % 3
secondindex = (last[1] - 1) % 3
dp = dict()
dp[0] = [0, 1, 2]
dp[1] = [3, 4, 5]
dp[2] = [6, 7, 8]
count = 0
for garo in dp[firstindex]:
	sero = secondindex
	for key in range(len(badook[garo][sero])):
		if badook[garo][sero][key] == '.':
			count = 1
			badook[garo][sero][key] = '!'
if count == 0:
	for i in badook:
		for j in i:
			for k in range(len(j)):
				if j[k] == '.':
					j[k] = '!'
for i in range(len(badook)):
	for j in range(len(badook[i])):
		for k in range(len(badook[i][j])):
			print(badook[i][j][k], end='')
		print(end=' ')
	print()
	if i == 2 or i == 5:
		print()


matr = [['' for j in range(9)] for i in range(9)]
r = 0
for i in range(11):
	if i == 3 or i == 7:
		input()
		continue
	k = 0
	for (j, x) in enumerate(input()):
		if x != ' ':
			matr[r][k] = x
			k += 1
	r += 1
(x, y) = map(int, input().split())
(x, y) = ((x - 1) % 3 * 3, (y - 1) % 3 * 3)
case = 0
for i in range(x, x + 3):
	for j in range(y, y + 3):
		if matr[i][j] == '.':
			case = 1
			matr[i][j] = '!'
if case == 0:
	for i in range(9):
		for j in range(9):
			if matr[i][j] == '.':
				matr[i][j] = '!'
for (i, x) in enumerate(matr):
	if i == 3 or i == 6:
		print()
	for (j, y) in enumerate(x):
		if j == 3 or j == 6:
			print(' ', end='')
		print(y, end='')
	print()


field = list(filter(lambda l: l is not None, [input().strip().replace(' ', '') if i not in [3, 7] else (input(), None)[1] for i in range(11)]))
(y, x) = map(int, input().split())
x -= 1
y -= 1
x = x % 3
y = y % 3
flag = False
for i in range(y * 3, y * 3 + 3):
	mut = list(field[i])
	for u in range(x * 3, x * 3 + 3):
		if mut[u] == '.':
			flag = True
			mut[u] = '!'
	field[i] = ''.join(mut)
if not flag:
	for i in range(len(field)):
		field[i] = field[i].replace('.', '!')
for u in range(len(field)):
	if u in [3, 6]:
		print()
	i = field[u]
	print('{} {} {}'.format(i[:3], i[3:6], i[6:]))


def main():
	ls = []
	for i in range(11):
		l = list(filter(lambda c: c != ' ', input()))
		if l:
			ls.append(l)
	(r, c) = list(map(lambda c: int(c) - 1, input().split(' ')))
	flag = False
	(cr, cc) = (r % 3, c % 3)
	for i in range(cr * 3, cr * 3 + 3):
		for j in range(cc * 3, cc * 3 + 3):
			if ls[i][j] not in ['x', 'o']:
				ls[i][j] = '!'
				flag = True
	if not flag:
		for i in range(9):
			for j in range(9):
				if ls[i][j] not in ['x', 'o']:
					ls[i][j] = '!'
	for i in range(3):
		for j in range(3):
			l = ls[i * 3 + j]
			print(' '.join(map(lambda xx: ''.join(xx), [l[0:3], l[3:6], l[6:9]])))
		print('')
main()


import sys
input = sys.stdin.readline
grid = []
for z in range(3):
	for i in range(3):
		grid.append([x for x in input().strip('\n') if x != ' '])
	useless = input()
(a, b) = map(int, useless.split())
if a % 3 == 0:
	a = 6
elif a % 3 == 1:
	a = 0
else:
	a = 3
if b % 3 == 0:
	b = 6
elif b % 3 == 1:
	b = 0
else:
	b = 3
count = 0
for i in range(a, a + 3):
	for j in range(b, b + 3):
		if grid[i][j] == '.':
			count += 1
			grid[i][j] = '!'

def printGrid():
	for i in range(9):
		grid[i].insert(3, ' ')
		grid[i].insert(7, ' ')
	for i in range(9):
		print(''.join(grid[i]))
		if i % 3 == 2 and i != 8:
			print('')
if count != 0:
	printGrid()
	exit(0)
for i in range(9):
	for j in range(9):
		if grid[i][j] == '.':
			count += 1
			grid[i][j] = '!'
printGrid()


mp = []
for ii in range(11):
	if ii == 3 or ii == 7:
		input()
		continue
	mp.append(list(''.join([str(i) for i in input().split(' ')])))
(y, x) = [int(i) for i in input().split(' ')]
r = y % 3
c = x % 3
cnt = 0
rr = (3 + r - 1) % 3
cc = (3 + c - 1) % 3
for i in range(3):
	for j in range(3):
		if mp[rr * 3 + i][cc * 3 + j] == '.':
			mp[rr * 3 + i][cc * 3 + j] = '!'
			cnt += 1
if cnt == 0:
	for i in range(9):
		for j in range(9):
			if mp[i][j] == '.':
				mp[i][j] = '!'
for i in range(9):
	if i == 3 or i == 6:
		print('')
	for j in range(9):
		if j == 3 or j == 6:
			print(' ', end='')
		print(mp[i][j], end='')
		if j == 8:
			print('')


S = [[0] * 3 for i in range(3)]
s1 = [list(map(list, input().split())) for i in range(3)]
input()
S[0][0] = [s1[0][0], s1[1][0], s1[2][0]]
S[0][1] = [s1[0][1], s1[1][1], s1[2][1]]
S[0][2] = [s1[0][2], s1[1][2], s1[2][2]]
s2 = [list(map(list, input().split())) for i in range(3)]
input()
S[1][0] = [s2[0][0], s2[1][0], s2[2][0]]
S[1][1] = [s2[0][1], s2[1][1], s2[2][1]]
S[1][2] = [s2[0][2], s2[1][2], s2[2][2]]
s3 = [list(map(list, input().split())) for i in range(3)]
S[2][0] = [s3[0][0], s3[1][0], s3[2][0]]
S[2][1] = [s3[0][1], s3[1][1], s3[2][1]]
S[2][2] = [s3[0][2], s3[1][2], s3[2][2]]
(x, y) = map(int, input().split())
(x, y) = (x - 1, y - 1)
x %= 3
y %= 3
s = S[x][y]
cnt = 0
for i in range(3):
	for j in range(3):
		if s[i][j] == '.':
			s[i][j] = '!'
			cnt += 1
if cnt != 0:
	S[x][y] = s
else:
	for i in range(3):
		for j in range(3):
			s = S[i][j]
			for k in range(3):
				for l in range(3):
					if s[k][l] == '.':
						s[k][l] = '!'
			S[i][j] = s
for i in range(3):
	print(''.join(S[0][0][i]), ''.join(S[0][1][i]), ''.join(S[0][2][i]))
print()
for i in range(3):
	print(''.join(S[1][0][i]), ''.join(S[1][1][i]), ''.join(S[1][2][i]))
print()
for i in range(3):
	print(''.join(S[2][0][i]), ''.join(S[2][1][i]), ''.join(S[2][2][i]))
print()


b = [list(''.join(input().split())) for i in range(11)]
g = [[[[0] * 3 for _ in range(3)] for _ in range(3)] for _ in range(3)]
b.remove([])
b.remove([])
for i in range(9):
	for j in range(9):
		g[i // 3][j // 3][i % 3][j % 3] = b[i][j]
(x, y) = map(int, input().split())
x = (x - 1) % 3
y = (y - 1) % 3
grid = g[x][y]
c = 0
for p in grid:
	c += p.count('.')
if c != 0:
	for p in range(3):
		for q in range(3):
			if grid[p][q] == '.':
				grid[p][q] = '!'
	g[x][y] = grid
else:
	for i in range(9):
		for j in range(9):
			if g[i // 3][j // 3][i % 3][j % 3] == '.':
				g[i // 3][j // 3][i % 3][j % 3] = '!'
for i in range(9):
	for j in range(9):
		b[i][j] = g[i // 3][j // 3][i % 3][j % 3]
for i in range(9):
	print(''.join(b[i][:3]), ''.join(b[i][3:6]), ''.join(b[i][6:]), sep=' ')
	if i % 3 == 2:
		print()


board = [list(input()) for i in range(11)]
(x, y) = map(int, input().split())
x = (x - 1) % 3
y = (y - 1) % 3
can = False
for i in range(3):
	for j in range(3):
		if board[x * 4 + i][y * 4 + j] == '.':
			board[x * 4 + i][y * 4 + j] = '!'
			can = True
if not can:
	for i in range(11):
		if i % 4 != 3:
			for j in range(11):
				if board[i][j] == '.':
					board[i][j] = '!'
for i in range(11):
	print(''.join(board[i]))


import sys
import string
arr = list((input().split(' ') for a in range(0, 11)))
for a in arr:
	if len(a) == 1:
		arr.remove(a)
(n, m) = map(int, input().split(' '))
n = (n - 1) % 3 * 3
m = (m - 1) % 3 * 3
ok = False
for i in range(0, 3):
	if arr[n + i][m // 3].find('.') != -1:
		arr[n + i][m // 3] = arr[n + i][m // 3].replace('.', '!')
		ok = True
arr.insert(3, '')
arr.insert(7, '')
if ok:
	for a in arr:
		print(' '.join(a))
else:
	for a in arr:
		print(' '.join(a).replace('.', '!'))


mtx = []
for i in range(11):
	inp = input()
	if inp.strip():
		mtx.append(list(''.join(inp.split())))
(y, x) = map(int, input().split())
y -= 1
x -= 1
gx = x % 3
gy = y % 3
found = 0
for px in range(3):
	for py in range(3):
		if mtx[gy * 3 + py][gx * 3 + px] == '.':
			mtx[gy * 3 + py][gx * 3 + px] = '!'
			found += 1
if not found:
	for px in range(9):
		for py in range(9):
			if mtx[py][px] == '.':
				mtx[py][px] = '!'
for i in range(9):
	st = ''
	for j in range(9):
		st += mtx[i][j]
		if j == 2 or j == 5:
			st += ' '
	print(st)
	if i == 2 or i == 5:
		print()


def solve():
	M = [list(input().strip().replace(' ', '')) for _ in range(11)]
	del M[3::4]
	(X, Y) = map(int, input().strip().split())
	(X, Y) = (X - 1, Y - 1)
	(lx, ly) = (X % 3, Y % 3)
	unchanged = True
	print('\n'.join((''.join(line) for line in M)))
	for x in range(9):
		for y in range(9):
			if x // 3 == lx and y // 3 == ly and (M[x][y] == '.'):
				M[x][y] = '!'
				unchanged = False
	if unchanged:
		for x in range(9):
			for y in range(9):
				if M[x][y] == '.':
					M[x][y] = '!'
	M = [''.join(line) for line in M]
	M = ['{} {} {} '.format(line[:3], line[3:6], line[6:]) for line in M]
	M = '{}\n\n{}\n\n{}'.format('\n'.join(M[:3]), '\n'.join(M[3:6]), '\n'.join(M[6:]))
	return M
_testcases = '\n... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4\n__________________\n... ... ... \n... ... ... \n... ... ... \n\n... ... ... \n... ... ... \n... x.. ... \n\n!!! ... ... \n!!! ... ... \n!!! ... ... \n__________________\nxoo x.. x..\nooo ... ...\nooo ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n7 4\n__________________\nxoo x!! x!! \nooo !!! !!! \nooo !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n__________________\no.. ... ...\n... ... ...\n... ... ...\n\n... xxx ...\n... xox ...\n... ooo ...\n\n... ... ...\n... ... ...\n... ... ...\n5 5\n__________________\no!! !!! !!! \n!!! !!! !!! \n!!! !!! !!! \n\n!!! xxx !!! \n!!! xox !!! \n!!! ooo !!! \n\n!!! !!! !!! \n!!! !!! !!! \n!!! !!! !!! \n'.strip()
from bisect import bisect_left, bisect_right
from collections import defaultdict
from functools import lru_cache
from heapq import heapify, heappop, heappush
from operator import itemgetter, attrgetter
import bisect
import collections
import functools
import heapq
import itertools
import math
import operator
import re
import string
import sys
inf = float('inf')
cache = lru_cache(None)
sys.setrecursionlimit(10000)

def tree():
	return collections.defaultdict(tree)

def equal(x, y, epsilon=1e-06):
	if -epsilon <= x - y <= epsilon:
		return True
	if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
		return False
	return -epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon

def get(_type):
	if type(_type) == list:
		if len(_type) == 1:
			_type = _type[0]
			return list(map(_type, input().strip().split()))
		else:
			return [_type[i](inp) for (i, inp) in enumerate(input().strip().split())]
	else:
		return _type(input().strip())
printRecursionTree = timeit = lambda x: x
(_p, print) = (print, lambda *a, **b: None)
_p(solve())


M = []
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
input()
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
input()
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
M.append(list(input().replace(' ', '')))
(y, x) = [int(x) - 1 for x in input().split()]
lx = 3 * (x % 3)
ly = 3 * (y % 3)
full = True
for x in range(3):
	for y in range(3):
		if M[ly + x][lx + y] == '.':
			M[ly + x][lx + y] = '!'
			full = False
if full:
	i = 0
	for m in M:
		s = ''.join(m).replace('.', '!')
		print(s[:3], s[3:6], s[6:])
		i += 1
		if i == 3 or i == 6:
			print()
else:
	i = 0
	for m in M:
		s = ''.join(m)
		print(s[:3], s[3:6], s[6:])
		i += 1
		if i == 3 or i == 6:
			print()


import sys

class XO:

	def __init__(self):
		self.state = []
		self.x = 0
		self.y = 0
		self.last_player = 0

	def add_line(self, line: str):
		state_line = []
		for n in range(9):
			pos = n // 3 + n
			char = line[pos]
			if char == 'x':
				state_line.append(1)
			elif char == 'o':
				state_line.append(2)
			else:
				state_line.append(0)
		self.state.append(state_line)

	def __str__(self):
		lines = []
		n = 0
		for state_line in self.state:
			if n == 3 or n == 6:
				lines.append('')
			n += 1
			line = ''
			for pos in range(9):
				if pos == 3 or pos == 6:
					line += ' '
				value = state_line[pos]
				if value == 3:
					line += '!'
				elif value == 2:
					line += 'o'
				elif value == 1:
					line += 'x'
				else:
					line += '.'
			lines.append(line)
		return '\n'.join(lines)

	def set_xy(self, row, col):
		self.x = col - 1
		self.y = row - 1
		self.last_player = self.state[self.y][self.x]

	def mini_has_empty_cells(self, mini_x, mini_y):
		st_x = mini_x * 3
		st_y = mini_y * 3
		for y in range(3):
			for x in range(3):
				if self.state[st_y + y][st_x + x] == 0:
					return True
		return False

	def fill_mini(self, mini_x, mini_y):
		st_x = mini_x * 3
		st_y = mini_y * 3
		for y in range(3):
			for x in range(3):
				if self.state[st_y + y][st_x + x] == 0:
					self.state[st_y + y][st_x + x] = 3

	def fill_all(self):
		for y in range(9):
			for x in range(9):
				if self.state[y][x] == 0:
					self.state[y][x] = 3

	def process(self):
		mini_x = self.x % 3
		mini_y = self.y % 3
		if self.mini_has_empty_cells(mini_x, mini_y):
			self.fill_mini(mini_x, mini_y)
		else:
			self.fill_all()
		pass
xo = XO()
xo.add_line(input())
xo.add_line(input())
xo.add_line(input())
input()
xo.add_line(input())
xo.add_line(input())
xo.add_line(input())
input()
xo.add_line(input())
xo.add_line(input())
xo.add_line(input())
xy = input().split(' ')
xo.set_xy(int(xy[0]), int(xy[1]))
xo.process()
print(xo)


def is_full(board, x, y):
	for a in range(3):
		for b in range(3):
			if board[x * 3 + a][y * 3 + b] not in ['o', 'x']:
				return False
	return True

def fill_board(board, exclude, x, y):
	if exclude:
		for a in range(9):
			for b in range(9):
				if not (x * 3 <= a <= x * 3 + 2 and y * 3 <= b <= y * 3 + 2):
					if board[a][b] not in ['o', 'x']:
						board[a][b] = '!'
	else:
		for a in range(3):
			for b in range(3):
				if board[x * 3 + a][y * 3 + b] not in ['o', 'x']:
					board[x * 3 + a][y * 3 + b] = '!'

class CodeforcesTask907BSolution:

	def __init__(self):
		self.result = ''
		self.board = []
		self.last_move = []

	def read_input(self):
		for x in range(11):
			in_ = input()
			if in_:
				self.board.append(list(in_.replace(' ', '')))
		self.last_move = [int(x) for x in input().split(' ')]

	def process_task(self):
		fill_board(self.board, is_full(self.board, *[(x - 1) % 3 for x in self.last_move]), *[(x - 1) % 3 for x in self.last_move])
		out_board = [' '.join([''.join(x) for x in [row[:3], row[3:6], row[6:]]]) for row in self.board]
		out_board = out_board[:3] + [''] + out_board[3:6] + [''] + out_board[6:]
		self.result = '\n'.join(out_board)

	def get_result(self):
		return self.result
Solution = CodeforcesTask907BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


def color(x1, y1, x2, y2):
	k = 0
	for i in range(x1, x2):
		for j in range(y1, min(len(field[i]), y2 + 1)):
			if field[i][j] == '.':
				field[i][j] = '!'
				k += 1
	return k != 0
field = [list(input()) for i in range(11)]
(x, y) = map(int, input().split())
xg = x % 3 + 3 * (x % 3 == 0)
yg = y % 3 + 3 * (y % 3 == 0)
x2 = 4 * xg - 1
y2 = 4 * yg - 1
x1 = x2 - 3
y1 = y2 - 3
if not color(x1, y1, x2, y2):
	color(0, 0, 11, 10)
for i in range(len(field)):
	for j in range(len(field[i])):
		print(field[i][j], end='')
	print()


(ul, um, ur, ml, mm, mr, ll, lm, lr) = ([], [], [], [], [], [], [], [], [])
for i in range(3):
	l = input().split()
	ul.append(l[0])
	um.append(l[1])
	ur.append(l[2])
input()
for i in range(3):
	l = input().split()
	ml.append(l[0])
	mm.append(l[1])
	mr.append(l[2])
input()
for i in range(3):
	l = input().split()
	ll.append(l[0])
	lm.append(l[1])
	lr.append(l[2])
(x, y) = map(int, input().split())
x = (x - 1) % 3 + 1
y = (y - 1) % 3 + 1
l = []
l.append([ul, um, ur])
l.append([ml, mm, mr])
l.append([ll, lm, lr])
flag = 0
for ele in l[x - 1][y - 1]:
	for ele2 in ele:
		if ele2 == '.':
			flag = 1
for i in range(3):
	for j in range(3):
		if l[x - 1][y - 1][i][j] == '.':
			l[x - 1][y - 1][i] = l[x - 1][y - 1][i][:j] + '!' + l[x - 1][y - 1][i][j + 1:]
if flag == 0:
	for i1 in range(3):
		for j1 in range(3):
			for i in range(3):
				for j in range(3):
					if l[i1][j1][i][j] == '.':
						l[i1][j1][i] = l[i1][j1][i][:j] + '!' + l[i1][j1][i][j + 1:]
for i in range(3):
	for j in range(3):
		print(l[i][0][j], l[i][1][j], l[i][2][j])
	print('')


field = [['.' for i in range(9)] for j in range(9)]
for l in range(3):
	for m in range(3):
		str = input().split(' ')
		for j in range(3):
			for k in range(3):
				field[l * 3 + m][j * 3 + k] = str[j][k]
	temp = input()
(x, y) = temp.split(' ')
x = (int(x) - 1) % 3
y = (int(y) - 1) % 3
flag = False
for i in range(x * 3, x * 3 + 3):
	for j in range(y * 3, y * 3 + 3):
		if field[i][j] == '.':
			flag = True
			field[i][j] = '!'
if flag == False:
	for i in range(9):
		for j in range(9):
			if field[i][j] == '.':
				field[i][j] = '!'
for l in range(3):
	for m in range(3):
		for j in range(3):
			for k in range(3):
				print(field[l * 3 + m][j * 3 + k], end='')
			print(' ', end='')
		print()
	print()


table = []
fields = []
(field1, field2, field3) = ([], [], [])
for row in range(11):
	if row != 3 and row != 7:
		nexus = [i for i in input() if i != ' ']
		table.append(nexus)
		field1.append(nexus[:3])
		field2.append(nexus[3:6])
		field3.append(nexus[6:9])
	elif row == 3 or row == 7:
		input()
		fields.extend([field1, field2, field3])
		(field1, field2, field3) = ([], [], [])
fields.extend([field1, field2, field3])
x_y = [int(i) - 1 for i in input().split()]
positions = []
for row in range(3):
	for column in range(3):
		coord = []
		for next_column in range(0, 7, 3):
			col = column + next_column
			r = row
			for next_row in range(0, 7, 3):
				coord.append([r + next_row, col])
		positions.append(coord)
for (order_num, candidate) in enumerate(positions):
	if x_y in candidate:
		flag = 0
		for row in fields[order_num]:
			for ind in range(3):
				if row[ind] == '.':
					row[ind] = '!'
					flag = 1
		if flag == 0:
			for string in fields:
				for row in string:
					for ind in range(3):
						row[ind] = '!' if row[ind] == '.' else row[ind]
for row in range(0, 7, 3):
	for column in range(3):
		for r in range(row, row + 3):
			print(*fields[r][column], sep='', end=' ')
		print()
	print()


def main():
	s = ''
	for i in range(11):
		tmp = input().split()
		for el in tmp:
			s += el
	last = [int(x) for x in input().split()]
	last[0] = last[0] % 3
	last[1] = last[1] % 3
	if last[0] == 0:
		last[0] += 3
	if last[1] == 0:
		last[1] += 3
	mtrx = [[] for i in range(9)]
	k = 0
	for i in range(9):
		for j in range(9):
			if s[k] == 'x':
				mtrx[i].append(1)
			elif s[k] == 'o':
				mtrx[i].append(2)
			else:
				mtrx[i].append(0)
			k += 1
	flag = True
	for i in range((last[0] - 1) * 3, last[0] * 3):
		for j in range((last[1] - 1) * 3, last[1] * 3):
			if mtrx[i][j] == 0:
				flag = False
				mtrx[i][j] = 3
	if flag:
		for i in range(9):
			for j in range(9):
				if mtrx[i][j] == 0:
					mtrx[i][j] = 3
	res = ''
	for i in range(3):
		for u in range(3):
			for j in range(3):
				for v in range(3):
					if mtrx[i * 3 + u][j * 3 + v] == 0:
						res += '.'
					elif mtrx[i * 3 + u][j * 3 + v] == 1:
						res += 'x'
					elif mtrx[i * 3 + u][j * 3 + v] == 2:
						res += 'o'
					else:
						res += '!'
				res += ' '
			res += '\n'
		res += '\n'
	print(res)
main()


def line():
	L = input().split()
	return list(''.join(L))
L = []
for i in range(0, 9):
	if i == 3 or i == 6:
		input()
	L.append(line())
(x, y) = map(int, input().split())
x -= 1
y -= 1
x %= 3
y %= 3
empt = True
for i in range(3 * x, 3 * (x + 1)):
	for j in range(3 * y, 3 * (y + 1)):
		if L[i][j] == '.':
			L[i][j] = '!'
			empt = False
for i in range(0, 9):
	if empt:
		L[i] = ''.join(L[i]).replace('.', '!')
	else:
		L[i] = ''.join(L[i])
for i in range(0, 9):
	if i == 3 or i == 6:
		print()
	print(L[i][:3], L[i][3:6], L[i][6:9])


x = [[m for m in input()] for y in range(11)]
(a, b) = map(int, input().split(' '))
(a, b) = ((a - 1) % 3, (b - 1) % 3)
targ = [(i, j) for i in range(3 * a, 3 * a + 3) for j in range(3 * b, 3 * b + 3)]
dic = {0: 0, 1: 1, 2: 2, 3: 4, 4: 5, 5: 6, 6: 8, 7: 9, 8: 10}
boo = True
for z in targ:
	cur = x[dic[z[0]]][dic[z[1]]]
	if cur == '.':
		x[dic[z[0]]][dic[z[1]]] = '!'
		boo = False
	else:
		pass
if boo:
	x = [['!' if l == '.' else l for l in k] for k in x]
for i in x:
	print(''.join(i))


arr = []
for i in range(11):
	row = input()
	if row != '':
		arr.append(list(row.replace(' ', '')))
coord = [int(x) for x in input().split(' ')]
subsquare = [coord[0] - (coord[0] - 1) // 3 * 3, coord[1] - (coord[1] - 1) // 3 * 3]
blocked = True
for i in range(3 * subsquare[0] - 3, 3 * subsquare[0]):
	for j in range(3 * subsquare[1] - 3, 3 * subsquare[1]):
		if arr[i][j] == '.':
			blocked = False
			arr[i][j] = '!'
if blocked:
	for i in range(9):
		for j in range(9):
			if arr[i][j] == '.':
				blocked = False
				arr[i][j] = '!'
for row in arr:
	row.insert(6, ' ')
	row.insert(3, ' ')
arr.insert(6, [' '])
arr.insert(3, [' '])
print('\n'.join([''.join(x) for x in arr]))


import sys
a = [['...' for j in range(3)] for i in range(9)]
l = 0
for i in range(11):
	if i == 3 or i == 7:
		k = input()
		continue
	b = input().split()
	for i in range(len(b)):
		a[l][i] = b[i]
	l += 1
(x, y) = map(int, input().split())
x -= 1
y -= 1
x %= 3
y %= 3
f = 0
for i in range(3 * x, 3 * x + 3):
	j = y
	for m in range(3):
		if a[i][j][m] == '.':
			f = 1
			if m == 0:
				a[i][j] = '!' + a[i][j][1:]
			elif m == 1:
				a[i][j] = a[i][j][0] + '!' + a[i][j][2]
			elif m == 2:
				a[i][j] = a[i][j][0] + a[i][j][1] + '!'
if not f:
	for i in range(9):
		for j in range(3):
			for m in range(3):
				if a[i][j][m] == '.':
					if m == 0:
						a[i][j] = '!' + a[i][j][1:]
					elif m == 1:
						a[i][j] = a[i][j][0] + '!' + a[i][j][2]
					elif m == 2:
						a[i][j] = a[i][j][0] + a[i][j][1] + '!'
for i in range(9):
	s = ''
	for j in range(3):
		s += a[i][j] + ' '
	print(s)
	if i == 2 or i == 5:
		print()


def f(x):
	x %= 3
	if x == 0:
		return 3
	return x

def g(x):
	if x == 1:
		return 0
	elif x == 2:
		return 4
	else:
		return 8
a = []
for i in range(3):
	a.append(input())
d = input()
a.append(11 * ' ')
for i in range(3):
	a.append(input())
d = input()
a.append(11 * ' ')
for i in range(3):
	a.append(input())
(x, y) = list(map(int, input().split()))
x = f(x)
y = f(y)
x = g(x)
y = g(y)
p = 0
for i in range(x, x + 3):
	for j in range(y, y + 3):
		if a[i][j] == '.':
			a[i] = a[i][:j] + '!' + a[i][j + 1:]
			p = 1
if p:
	for i in range(11):
		print(a[i])
else:
	for i in range(11):
		for j in range(11):
			if a[i][j] == '.':
				a[i] = a[i][:j] + '!' + a[i][j + 1:]
	for i in range(11):
		print(a[i])


grid = []
grid2 = []
for i in range(3):
	s = list(input().split())
	grid.append(s)
	s = ''.join(s)
	grid2.append(s)
s = input()
for i in range(3):
	s = list(input().split())
	grid.append(s)
	s = ''.join(s)
	grid2.append(s)
s = input()
for i in range(3):
	s = list(input().split())
	grid.append(s)
	s = ''.join(s)
	grid2.append(s)
(a, b) = map(int, input().split())
if a % 3 == 0:
	x = 3
elif a % 3 == 1:
	x = 1
else:
	x = 2
if b % 3 == 0:
	y = 3
elif b % 3 == 1:
	y = 1
else:
	y = 2
flag = 0
for i in range(3 * (x - 1), 3 * (x - 1) + 3):
	for j in range(3 * (y - 1), 3 * (y - 1) + 3):
		if grid2[i][j] == '.':
			flag = 1
if not flag:
	for i in range(9):
		li = list(grid2[i])
		for j in range(9):
			if grid2[i][j] == '.':
				li[j] = '!'
		grid2[i] = ''.join(li)
	for i in range(9):
		print(grid2[i][:3] + ' ' + grid2[i][3:6] + ' ' + grid2[i][6:])
		if (i + 1) % 3 == 0:
			print()
else:
	for i in range(9):
		li = list(grid2[i])
		for j in range(9):
			if 3 * (x - 1) <= i <= 3 * (x - 1) + 2 and 3 * (y - 1) <= j <= 3 * (y - 1) + 2:
				if grid2[i][j] == '.':
					li[j] = '!'
		grid2[i] = ''.join(li)
	for i in range(9):
		print(grid2[i][:3] + ' ' + grid2[i][3:6] + ' ' + grid2[i][6:])
		if (i + 1) % 3 == 0:
			print()


a = [''] * 11
for i in range(11):
	a[i] = list(input())
(x, y) = map(int, input().split())
k = 0
x1 = (x - 1) % 3
y1 = (y - 1) % 3
if y1 == 0:
	y2 = 2
if y1 == 1:
	y2 = 6
	y1 = 4
if y1 == 2:
	y2 = 10
	y1 = 8
if x1 == 0:
	x2 = 2
if x1 == 1:
	x2 = 6
	x1 = 4
if x1 == 2:
	x1 = 8
	x2 = 10
for i in range(x1, x2 + 1):
	for j in range(y1, y2 + 1):
		if a[i][j] == '.':
			a[i][j] = '!'
			k = 1
if k == 0:
	for i in range(11):
		for j in range(11):
			if i != 3 and i != 7 and (j != 3) and (j != 7):
				if a[i][j] == '.':
					a[i][j] = '!'
for row in a:
	print(''.join([str(elem) for elem in row]))
print()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
A = []
for i in range(11):
	s = input()
	A.append([*s])
(x, y) = ilele()
if x <= 3:
	i = x - 1
elif x <= 6:
	i = x
else:
	i = x + 1
if y <= 3:
	j = y - 1
elif y <= 6:
	j = y
else:
	j = y + 1
f = 0
if 0 <= i <= 2:
	a = 0
	b = 2
elif 4 <= i <= 6:
	a = 4
	b = 6
else:
	a = 8
	b = 10
if 0 <= j <= 2:
	c = 0
	d = 2
elif 4 <= j <= 6:
	c = 4
	d = 6
else:
	c = 8
	d = 10
k1 = i - a
k2 = j - c
if k1 == 0:
	a = 0
	b = 2
elif k1 == 1:
	a = 4
	b = 6
else:
	a = 8
	b = 10
if k2 == 0:
	c = 0
	d = 2
elif k2 == 1:
	c = 4
	d = 6
else:
	c = 8
	d = 10
for l in range(a, b + 1):
	for m in range(c, d + 1):
		if A[l][m] == '.':
			f = 1
			A[l][m] = '!'
if f == 0:
	for i in range(len(A)):
		if A[i]:
			for j in range(len(A[0])):
				if A[i][j] == '.':
					A[i][j] = '!'
for i in A:
	if i:
		print(''.join(i))
	else:
		print()


def main():

	def get_cell(x, y):
		(r, c) = (0, 0)
		if x <= 2:
			r = 0
		elif x <= 5:
			r = 1
		elif x <= 8:
			r = 2
		if y <= 2:
			c = 0
		elif y <= 5:
			c = 1
		elif y <= 8:
			c = 2
		return (r, c)

	def get_cells(grids, fx, fy):
		count = 0
		for i in range(3):
			for j in range(3):
				if grids[fx][fy][i][j] == '.':
					grids[fx][fy][i][j] = '!'
					count += 1
		return count
	g = []
	for i in range(11):
		l = ''.join(input().split())
		if len(l) > 0:
			g.append(list(l))
	grids = []
	for k in range(3):
		gg = []
		for j in range(3):
			ggg = []
			for i in range(3 * k, 3 * k + 3):
				ggg.append(g[i][j * 3:j * 3 + 3])
			gg.append(ggg)
		grids.append(gg)
	(x, y) = map(int, input().split(' '))
	x -= 1
	y -= 1
	(cx, cy) = get_cell(x, y)
	(fx, fy) = (x, y)
	while fx >= 3:
		fx -= 3
	while fy >= 3:
		fy -= 3
	count = get_cells(grids, fx, fy)
	if count == 0:
		for i in range(3):
			for j in range(3):
				get_cells(grids, i, j)
	ret = []
	for k in range(3):
		for j in range(3):
			x = []
			for i in range(3):
				x.append(''.join(grids[k][i][j]))
			ret.append(x)
		ret.append('')
	for thing in ret:
		print(' '.join(thing))
main()


import sys
sys.setrecursionlimit(1000000)
read = sys.stdin.readline
field = ['' for _ in range(9)]
for i in range(3):
	for j in range(3):
		try:
			(l, m, r) = read().strip().split()
		except ValueError:
			(l, m, r) = read().strip().split()
		field[i * 3] += l
		field[i * 3 + 1] += m
		field[i * 3 + 2] += r
(x, y) = map(int, read().split())
idx = (x - 1) // 3 * 3 + (y - 1) // 3
inIdx = (x - 1) % 3 * 3 + (y - 1) % 3
if '.' in field[inIdx]:
	field[inIdx] = field[inIdx].replace('.', '!')
else:
	for i in range(len(field)):
		field[i] = field[i].replace('.', '!')
for i in range(3):
	for j in range(3):
		print(field[i * 3][j * 3:j * 3 + 3], field[i * 3 + 1][j * 3:j * 3 + 3], field[i * 3 + 2][j * 3:j * 3 + 3])
	if i in (0, 1):
		print('')


grid = []
for count in range(11):
	i = input().replace(' ', '')
	if i == '':
		continue
	grid += [list(i)]
(x, y) = list(map(int, input().split()))
x -= 1
y -= 1

def show(ar):
	s = ''
	for counter in range(1, 10):
		s += ar[counter - 1]
		if counter % 3 == 0:
			s += ' '
	print(s)
x = x % 3 * 3
y = y % 3 * 3
tot = 0
for i in range(x, x + 3):
	for j in range(y, y + 3):
		if grid[i][j] == '.':
			grid[i][j] = '!'
			tot += 1
if tot == 0:
	for i in range(9):
		for j in range(9):
			if grid[i][j] == '.':
				grid[i][j] = '!'
for a in range(9):
	row = grid[a]
	show(row)
	if a % 3 == 2:
		print()


s = []
q = []
S = []
s.append(input().split())
s.append(input().split())
s.append(input().split())
q.append(input().split())
s.append(input().split())
s.append(input().split())
s.append(input().split())
q.append(input().split())
s.append(input().split())
s.append(input().split())
s.append(input().split())
(x, y) = list(map(lambda x: int(x), input().split()))
X = x % 3
if x % 3 == 0:
	X = 3
Y = y % 3
if y % 3 == 0:
	Y = 3
ss = list(map(lambda x: ''.join(x), s[(X - 1) * 3:X * 3]))
qwe = []
ss = [ss[0][(Y - 1) * 3:Y * 3]] + [ss[1][(Y - 1) * 3:Y * 3]] + [ss[2][(Y - 1) * 3:Y * 3]]
for i in range((X - 1) * 3, X * 3):
	for j in range((Y - 1) * 3, Y * 3):
		qwe.append((i, j))
m = False
ss_new = []
for (i, el) in enumerate(ss):
	if '.' in el:
		m = True
	ss_new.append(el.replace('.', '!'))
sch = 0
if not m:
	for el in s:
		for ell in el[:-1]:
			print(ell.replace('.', '!'), end=' ')
		print(el[-1].replace('.', '!'))
		sch += 1
		if sch % 3 == 0 and sch != 9:
			print()
else:
	s_new = []
	sch_str = 0
	for el in s:
		s_new.append(''.join(el))
	for i in range(len(s_new)):
		sch_tab = 0
		for j in range(len(s_new[i])):
			if (i, j) in qwe:
				print(ss_new[i % 3][j % 3], end='')
				pass
			else:
				print(s_new[i][j], end='')
				pass
			sch_tab += 1
			if sch_tab % 3 == 0 and sch_tab != 9:
				print(' ', end='')
		print()
		sch_str += 1
		if sch_str % 3 == 0 and sch_str != 9:
			print()


g = [[[[0, 0, 0], [0, 0, 0], [0, 0, 0]] for j in range(3)] for i in range(3)]
for i in range(9):
	s = [list(map(lambda t: 0 if t == '.' else 1 if t == 'x' else -1, list(r))) for r in input().split()]
	for j in range(3):
		g[i // 3][j][i % 3] = s[j]
	if i % 3 == 2 and i != 8:
		input()
(x, y) = map(lambda i: int(i) - 1, input().split())
xi = g[x // 3][y // 3][x % 3][y % 3]
f = any((i == 0 for s in g[x % 3][y % 3] for i in s))
m = lambda c, xg, yg: '!' if c == 0 and ((xg, yg) == (x % 3, y % 3) or not f) else 'x' if c == 1 else 'o' if c == -1 else '.'
for i in range(9):
	print(' '.join((''.join((m(g[i // 3][j][i % 3][ji], i // 3, j) for ji in range(3))) for j in range(3))))
	if i % 3 == 2:
		print('')


org = []
for i in range(11):
	if i != 3 and i != 7:
		row = input().split()
		org.append(row)
	else:
		input()
(x, y) = input().split()
x = int(x) % 3
y = int(y) % 3
if x == 0:
	x = 3
if y == 0:
	y = 3
tgt = []
for j in range(3):
	tgt.append(org[3 * x - 3 + j][y - 1])
tmp = 0
for w in range(3):
	c = tgt[w]
	for k in range(3):
		if c[k] == '.':
			if k == 0:
				c = '!' + c[1:]
			if k == 1:
				c = c[0] + '!' + c[2]
			if k == 2:
				c = c[:2] + '!'
			tmp += 1
	tgt[w] = c
if tmp != 0:
	for q in range(3):
		org[3 * x - 3 + q][y - 1] = tgt[q]
if tmp == 0:
	for p in range(9):
		for l in range(3):
			for b in range(3):
				if org[p][l][b] == '.':
					if b == 0:
						org[p][l] = '!' + org[p][l][1:]
					if b == 1:
						org[p][l] = org[p][l][0] + '!' + org[p][l][2]
					if b == 2:
						org[p][l] = org[p][l][:2] + '!'
for v in range(9):
	if v % 3 == 2:
		sp = ''
		for h in range(3):
			sp += org[v][h] + ' '
		print(sp)
		print()
	else:
		sp = ''
		for u in range(3):
			sp += org[v][u] + ' '
		print(sp)


ls = []
for i in range(11):
	x = input()
	ls.append(x)
y = input().split()
l = int(y[0])
m = int(y[1])
ls2 = [8, 0, 4]
row_check = []
initial = ls2[l % 3]
for i in range(3):
	row_check.append(initial)
	initial += 1
column_check = []
initial = ls2[m % 3]
for i in range(3):
	column_check.append(initial)
	initial += 1
count = 0
for i in row_check:
	dummy = list(ls[i])
	for j in column_check:
		if dummy[j] == '.':
			count += 1
			dummy[j] = '!'
	ls[i] = ''.join(dummy)
if count == 0:
	for i in range(11):
		dummy = list(ls[i])
		for j in range(len(dummy)):
			if dummy[j] == '.':
				dummy[j] = '!'
		ls[i] = ''.join(dummy)
for i in range(11):
	print(ls[i])