gr = []
for i in range(0,11):
	ar = map(str, raw_input().split())
	if len(ar) != 0:
		st = ar[0]+ar[1]+ar[2]
		gr.append(st)

a = map(int, raw_input().split())
def  w( x, y,gr):
	fl = 0
	gg = gr[:]
	for i in range(x*3, x*3+3):
		ss = ''
		for j in range(y*3,y*3+3):
			if gg[i][j] == '.':
				ss += '!'
				fl = 1
			else:
				ss += gg[i][j]
		gg[i] = gg[i][:y*3] +ss+gg[i][y*3+3:]
	if fl == 1:
		return gg
	else:
		return -1

x = (a[0]-1)%3
y = (a[1]-1)%3
if w(x,y,gr) == -1:
	for i in range(0,9):
		ss = ''
		for j in range(0, 9):
			if gr[i][j] == '.':
				ss = ss+'!'
			else:
				ss = ss+gr[i][j]
		gr[i] = ss
	for i in range(0,9):
		for j in range(0,7,3):
			print gr[i][j:j+3],
		print
		if i == 2 or i==5:
			print
else:
	gr = w(x,y,gr)
	for i in range(0,9):
		for j in range(0, 7, 3):
			print gr[i][j:j+3],
		print
		if i == 2 or i==5:

			print

pole = [[], [], [], [], [], [], [], [], []]
for i in range(3):
        for k in range(3):
                a = input().split()
                pole[i * 3].append(a[0])
                pole[i * 3 + 1].append(a[1])
                pole[i * 3 + 2].append(a[2])
        k = input()
k = list(map(int, k.split()))
i1 = (k[0] - 1) % 3
i2 = (k[1] - 1) % 3
ix = i1 * 3 + i2
if '.' not in ''.join(pole[ix]):
        for i in range(9):
                for k in range(3):
                        n = ''
                        for l in list(pole[i][k]):
                                if l == '.':
                                        n += '!'
                                else:
                                        n += l
                        pole[i][k] = n
else:
        for i in range(3):
                n = ''
                for l in list(pole[ix][i]):
                        if l == '.':
                                n += '!'
                        else:
                                n += l
                pole[ix][i] = n
for i in range(3):
        for k in range(3):
                print(pole[i * 3][k], pole[i * 3 + 1][k], pole[i * 3 + 2][k])
        print()

a = [[] for i in range(9)]
for i in range(2):
    for j in range(3):
        b = input()
        a[3 * i + j].append(b[0])
        a[3 * i + j].append(b[1])
        a[3 * i + j].append(b[2])
        a[3 * i + j].append(b[4])
        a[3 * i + j].append(b[5])
        a[3 * i + j].append(b[6])
        a[3 * i + j].append(b[8])
        a[3 * i + j].append(b[9])
        a[3 * i + j].append(b[10])
    b = input()
for j in range(3):
    b = input()
    a[j + 6].append(b[0])
    a[j + 6].append(b[1])
    a[j + 6].append(b[2])
    a[j + 6].append(b[4])
    a[j + 6].append(b[5])
    a[j + 6].append(b[6])
    a[j + 6].append(b[8])
    a[j + 6].append(b[9])
    a[j + 6].append(b[10])
y, x = [int(x) for x in input().split()]
x2 = (x - 1) % 3
y2 = (y - 1) % 3
x2 *= 3
y2 *= 3
f = 1
for i in range(3):
    for j in range(3):
        if a[i + y2][j + x2] == '.':
            a[i + y2][j + x2] = '!'
            f = 0
if f == 1:
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.':
                a[i][j] = '!'
for i in range(3):
    for j in range(3):
        for l in range(3):
            print(a[3 * i + j][l], end='')
        print(' ', end='')
        for l in range(3, 6):
            print(a[3 * i + j][l], end='')
        print(' ', end='')
        for l in range(6, 9):
            print(a[3 * i + j][l], end='')
        print()
    print()

field = []

for i in range(3):
    for j in range(3):
        field.append(list(map(list, input().split())))

    if i != 2:
        input()

y, x = map(int, input().split())

x -= 1
y -= 1

f_x, f_y = x % 3, y % 3

placed_at_point = False

for i in range(f_y*3, f_y*3+3):
    for j in range(3):
        if field[i][f_x][j] == '.':
            field[i][f_x][j] = '!'
            placed_at_point = True

if not placed_at_point:
    for i in range(9):
        for j in range(3):
            for k in range(3):
                if field[i][j][k] == '.':
                    field[i][j][k] = '!'

for i in range(9):
    s = ''
    for j in field[i]:
        for k in j:
            s += k
        s += ' '
    print(s)
    if (i+1) % 3 == 0:
        print()

a = [[[['.'] * 3 for i in range(3)] for i in range(3)] for i in range(3)]

for i in range(3):
    s = input().split()
    for j in range(3):
        for h in range(3):
            ch = s[j][h]
            a[0][j][i][h] = ch
x = input()
for i in range(3):
    s = input().split()
    for j in range(3):
        for h in range(3):
            ch = s[j][h]
            a[1][j][i][h] = ch
x = input()
for i in range(3):
    s = input().split()
    for j in range(3):
        for h in range(3):
            ch = s[j][h]
            a[2][j][i][h] = ch

x, y = map(int, input().split())
x = x % 3 - 1
y = y % 3 - 1

fl = True

for i in range(3):
    for j in range(3):
        if a[x][y][i][j] == '.':
            fl = False
            a[x][y][i][j] = '!'

if fl:
    for x in range(3):
        for y in range(3):
            for i in range(3):
                for j in range(3):
                    if a[x][y][i][j] == '.':
                        a[x][y][i][j] = '!'

for i in range(3):
    for j in range(3):
        print(*a[0][j][i], sep='', end=' ')
    print()
print()
for i in range(3):
    for j in range(3):
        print(*a[1][j][i], sep='', end=' ')
    print()
print()
for i in range(3):
    for j in range(3):
        print(*a[2][j][i], sep='', end=' ')
    print()

a = []
for i in range(11):
    a.append(list(input().split()))
a.pop(3)
a.pop(6)
n, m = map(int, input().split())
n -= 1
m -= 1
n %= 3
m %= 3
n *= 3
state = 0
for i in range(3):
    for j in range(3):
        if a[n + i][m][j] == '.':
            a[n + i][m] = a[n + i][m][:j] + '!' + a[n + i][m][j + 1:]
            state = 1
if state == 0:
    for i in range(9):
        for j in range(3):
            for k in range(3):
                if a[i][j][k] == '.':
                    a[i][j] = a[i][j][:k] + '!' + a[i][j][k + 1:]
for i in range(9):
    for j in range(3):
        print(a[i][j], end = ' ')
    print()
    if i == 2 or i == 5:
        print()

def please_die(x):
    if x % 3 == 0:
        align_x = 2
    elif x % 3 == 1:
        align_x = 0
    else:
        align_x = 1
    return align_x

mas = []
s = []
ss = ''
for i in range(11):
    nn = input()
    if nn != '':
        s += nn.split(' ')
        ss += nn.replace(' ', '')

x, y = map(int, input().split())

mas.append(s[0]+s[3]+s[6])
mas.append(s[1]+s[4]+s[7])
mas.append(s[2]+s[5]+s[8])

mas.append(s[9]+s[12]+s[15])
mas.append(s[10]+s[13]+s[16])
mas.append(s[11]+s[14]+s[17])

mas.append(s[18]+s[21]+s[24])
mas.append(s[19]+s[22]+s[25])
mas.append(s[20]+s[23]+s[26])

align_x = -1
align_y = -1

align_x = please_die(x)

align_y = please_die(y)

what_a_square = align_x * 3 + align_y
if '.' in mas[what_a_square]:
    j = 0
    for i in s:
        xxx = j // 9 + 1
        yyy = j % 9 + 1
        if please_die(xxx) == align_x and please_die(yyy) == align_y:
            print(i.replace('.', '!'), end=' ')
        else:
            print(i, end=' ')
        j += 1
        if j % 3 == 0:
            print()
        if j % 9 == 0:
            print()
else:
    #all
    j = 0
    for i in s:
        print(i.replace('.','!'), end=' ')
        j += 1
        if j % 3 == 0:
            print()
        if j % 9 == 0:
            print()

field = [[0] for i in range(11)]
for i in range(11):
    field[i] = input().replace(" ", "")
save = field
field = []
for i in range(11):
    if(save[i] != ""):
        field.append([])
        for j in range(9):
            field[len(field) - 1].append(save[i][j])
x, y = map(int, input().split())
x, y = x - 1, y - 1
x1 = x % 3 * 3 + 1
y1 = y % 3 * 3 + 1
mark = False
for i in range(-1, 2):
    for j in range(-1, 2):
        if(field[x1 + i][y1 + j] == "."):
            mark = True
            field[x1 + i][y1 + j] = "!"
if not mark:
    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):
        print(field[i][j], end="")
        if((j + 1) % 3 == 0):
            print(end=" ")
    if((i + 1) % 3 == 0):
        print()
    print()

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

def inp():
    b = []
    for i in range(3):
        for j in range(3):
            s = input()
            s = s[:3] + s[4:7] + s[8:]
            b.append(list(s))
        if i!=2:
            input()
    return b
def out():
    for i in range(3):
        for j in range(3):
            s = a[i * 3 + j]
            print(s[0],s[1],s[2],' ', s[3],s[4],s[5],' ', s[6],s[7],s[8], sep = '')
        if i!=2:
            print()

a = inp()
x, y = map(int,input().split())
x -= 1
y -= 1
x %= 3
y %= 3
f = True
for i in range(3):
    for j in range(3):
        if a[x * 3 + i][y * 3 + j] == '.':
            a[x * 3 + i][y * 3 + j] = '!'
            f = False
if f:
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.':
                 a[i][j] = '!'
out()

l=[list(''.join(s.split())) for s in (input() for _ in range(11)) if s]
x,y=map(int, input().split())
a,b=(x-1)%3*3,(y-1)%3*3
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(9):
        for j in range(9):
            if l[i][j]=='.':
                l[i][j]='!'
for i in range(0,9,3):
    for j in range(3):
        s=''.join(l[i+j])
        print(' '.join((s[:3],s[3:6],s[6:])))
    print()

z=[]
for i in range(11):
    if (i!=3 and i!=7):
        a,b,c=input().split()
        l=a+b+c
        z.append(l)
    else:
        p=input()

y,x=map(int,input().split())
y=(y-1)%3
x=(x-1)%3
flag=0
for i in range(y*3,y*3+3):
    for j in range(x*3,x*3+3):
        if z[i][j]=='.':
            flag=1
if flag==1:
    for i in range(9):
        for j in range(9):
            if (i>=(y*3)) and (i<(y*3+3)) and (j>=(x*3)) and (j<(x*3+3)):
                if z[i][j]=='.':
                    print('!',end='')
                else:
                    print(z[i][j],end='')
            else:
                print(z[i][j],end='')
            if ((j+1)%3==0) and j!=8:
                print(' ',end='')
            if (j==8):
                print()
        if ((i+1)%3==0) and i!=8:
            print()
else:
    for i in range(9):
        for j in range(9):
            if z[i][j]=='.':
                print('!',end='')
            else:
                print(z[i][j],end='')
            if ((j+1)%3==0) and j!=8:
                print(' ',end='')
            if (j==8):
                print()
        if ((i+1)%3==0) and i!=8:
            print()

g=[list(input()) for _ in range(11)]
r,c=map(lambda x:(int(x)-1)%3*4,input().split())
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))

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

R=input
g=[list(R()) for _ in range(11)]
r,c=map(lambda x:(int(x)-1)%3*4,R().split())
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))

g = [[],[],[],[],[],[],[],[],[]]
for i in range(3):
    s = input().split()
    g[0].append((' '.join(j for j in s[0])).split())
    g[1].append((' '.join(j for j in s[1])).split())
    g[2].append((' '.join(j for j in s[2])).split())
la = input()
for i in range(3):
    s = input().split()
    g[3].append((' '.join(j for j in s[0])).split())
    g[4].append((' '.join(j for j in s[1])).split())
    g[5].append((' '.join(j for j in s[2])).split())
la = input()
for i in range(3):
    s = input().split()
    g[6].append((' '.join(j for j in s[0])).split())
    g[7].append((' '.join(j for j in s[1])).split())
    g[8].append((' '.join(j for j in s[2])).split())
z = input().split()
z[0] = int(z[0])
z[1] = int(z[1])
z[0]%=3
z[1]%=3
x = z[0]
y = z[1]
ref  = 0
if x==1 and y == 1:
    ref  = 0
if x==1 and y == 2:
    ref  = 1
if x==1 and y == 0:
    ref  = 2

if x==2 and y == 1:
    ref  = 3
if x==2 and y == 2:
    ref  = 4
if x==2 and y == 0:
    ref  = 5

if x==0 and y == 1:
    ref  = 6
if x==0 and y == 2:
    ref  = 7
if x==0 and y == 0:
    ref  = 8
def check(g):
    for i in g:
        for j in i:
            if j=='.':
                return True
    return False
if check(g[ref]):
    for i in range(3):
        for j in range(3):
            if(g[ref][i][j]=='.'):
                g[ref][i][j]= '!'
else:
    for i in range(9):
        for j in range(3):
            for k in range(3):
                if(g[i][j][k]=='.'):
                    g[i][j][k] = '!'

ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)
ans = ''
print()
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)
ans = ''
print()
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)

field = []
for i in range(3):
    for j in range(3):
        line = input().split()
        field.append(''.join(line))
    a = list(map(int, input().split()))

a, b = a[0], a[1]
c, d = a%3 + (3*(a%3==0)), b%3 + (3*(b%3==0))
#print(a, b, c, d)
isfree = 0
for i in range(3*(c-1), 3*c):
    for j in range(3*(d-1), 3*d):
        if field[i][j] == '.':
            isfree += 1

if not isfree:
    #print(isfree)
    for i in range(9):
        for j in range(9):
            if field[i][j] == '.':
                field[i] = field[i][:j] + '!' + field[i][j+1:]
else:
    for i in range(3*(c-1), 3*c):
        for j in range(3*(d-1), 3*d):
            if field[i][j] == '.':
                field[i] = field[i][:j] + '!' + field[i][j+1:]

for i in range(3):
    for j in range(3):
        print(field[3*i+j][:3], field[3*i+j][3:6], field[3*i+j][6:9])
    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))

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])

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]))

a = [[''] * 9 for i in range(9)]

for i in range(3):
    for j in range(3):
        q = input()
        q = q.replace(' ', '')
        for p in range(9):
            a[i * 3 + j][p] = q[p]
    if i != 2:
        q = input()

x, y = [int(i) for i in input().split()]
x1, y1 = x, y
while x1 > 3:
    x1 -= 3
while y1 > 3:
    y1 -= 3
x1 -= 1
y1 -= 1
ch = False
for i in range(3):
    for j in range(3):
        if a[i + x1 * 3][j + y1 * 3] == '.':
            ch = True
        if ch and a[i + x1 * 3][j + y1 * 3] == '.':
            a[i + x1 * 3][j + y1 * 3] = '!'
if not ch:
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.':
                a[i][j] = '!'
for i in range(3):
    for j in range(3):

        for p in range(3):
            for q in range(3):
                print(a[i * 3 + j][p * 3 + q], end='')
            print(' ', end='')
        print()
    print()

table = []

for i in range(2):
    for j in range(3):
        table.append(list(map(list, input().split())))
    input()

for i in range(3):
    table.append(list(map(list, input().split())))

y, x = map(int, input().split())

place = [(x-1)%3, (y-1)%3]

bool1 = True

for i in range(place[1]*3, place[1]*3+3):
    for j in range(len(table[i][place[0]])):
        if '.' == table[i][place[0]][j]:
            table[i][place[0]][j] = '!'
            bool1 = False

if bool1:
    for i in range(len(table)):
        for j in range(len(table[i])):
            for k in range(len(table[i][j])):
                if table[i][j][k] == '.' and (y-1 != i or x-1 // 3 != j or x-1 % 3 != k):
                    table[i][j][k] = '!'

for i in range(len(table)):
    for j in table[i]:
        for k in j:
            print(k, end='')
        print(end=' ')
    print()
    if (i+1) % 3 == 0:
        print()

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()

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:])

lines = []
for i in range(11):
    lines.append(input())
coords = list(map(int, input().split()))
sqy = (coords[0] - 1) % 3
sqx = (coords[1] - 1) % 3
startchange = False
sqstart = {0: 0, 1: 4, 2: 8}
changesyms = {'x': 'x', 'o': 'o', '.': '!', ' ': ' ', '\n': '\n'}
free = 0
toprint = ''
toprint2 = ''
for i in range(11):
    for i1 in range(len(lines[i])):
        if i in range(sqstart[sqy], sqstart[sqy] + 3) and i1 in range(sqstart[sqx], sqstart[sqx] + 3):
            startchange = True
        else:
            startchange = False
        if startchange:
            toprint += changesyms[lines[i][i1]]
            if changesyms[lines[i][i1]] != lines[i][i1]:
                free += 1
        else:
            toprint += lines[i][i1]
if free == 0:
    startchange = True
else:
    startchange = False
syms = 0
for i in toprint:
    if startchange:
        toprint2 += changesyms[i]
        if i not in changesyms:
            toprint2 += i
    else:
        toprint2 += i
    syms += 1
    if syms % 11 == 0 and syms != 99:
        toprint2 += '\n'
    if syms % 33 == 0 and syms != 99:
        toprint2 += '\n'
print(toprint2)

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()

A = []
for i in range(11):
    s = input()
    s = s.replace(" ", "")
    if s == "":
        continue
    A.append(list(s))
x, y = map(int, input().split())
x = (x-1) % 3
y = (y-1) % 3
#print(x, y)
rep = 0
for i in range(3):
    for j in range(3):
        if(A[3 * x + i][3 * y + j] == "."):
            A[3 * x + i][3 * y + j] = "!"
            rep += 1
if(rep == 0):
    for i in range(9):
        for j in range(9):
            if A[i][j] == ".":
                A[i][j] = "!"
for i in range(9):
    A[i] = A[i][0] + A[i][1] + A[i][2] + ' ' + A[i][3]  + A[i][4]  + A[i][5] + ' ' + A[i][6]  + A[i][7]  + A[i][8]

# for i in range(9):
#     for j in range(11):
#         print(A[i][j], end = '')
#     print()

for i in range(0,3):
    print(A[i])
print()

for i in range(3,6):
    print(A[i])
print()

for i in range(6,9):
    print(A[i])
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())

# nope = True
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()

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('')

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()

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def main():
	field = []
	for _ in range(3):
		s = input()
		s = s.replace(' ', '')
		field.append(list(s))
	input()
	for _ in range(3):
		s = input()
		s = s.replace(' ', '')
		field.append(list(s))
	input()
	for _ in range(3):
		s = input()
		s = s.replace(' ', '')
		field.append(list(s))
	x, y = map(int, input().split())
	x -= 1
	y -= 1
	x %= 3
	y %= 3
	x *= 3
	y *= 3
	cnt = 0
	for i in range(x, x + 3):
		for j in range(y, y + 3):
			if field[i][j] != '.':
				cnt += 1
	if cnt == 9:
		for i in range(9):
			for j in range(9):
				if field[i][j] == '.':
					field[i][j] = '!'
	else:
		for i in range(x, x + 3):
			for j in range(y, y + 3):
				if field[i][j] == '.':
					field[i][j] = '!'
	for i in range(9):
		print(' '.join([''.join(field[i][:3]), ''.join(field[i][3:6]), ''.join(field[i][6:])]))
		if not (i + 1) % 3 and not i == 8:
			print()

if __name__ == '__main__':
	main()

#!/usr/bin/env python3

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("")

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')

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])

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)

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()

spot = [[0] for i in range(11)]
check = False
for i in range(11):
    spot[i] = input().replace(" ", "")
data = spot
spot = []
for i in range(11):
    if (data[i] != ""):
        spot.append([])
        for j in range(9):
            spot[len(spot) - 1].append(data[i][j])
x, y = [int(z) for z in input().split()]
coordinate1 = (x - 1) % 3 * 3 + 1
coordinate2 = (y - 1) % 3 * 3 + 1
for i in range(-1, 2):
    for j in range(-1, 2):
        if (spot[coordinate1 + i][coordinate2 + j] == "."):
            check = True
            spot[coordinate1 + i][coordinate2 + j] = "!"
if check == False:
    for i in range(9):
        for j in range(9):
            if(spot[i][j] == "."):
                spot[i][j] = "!"

for i in range(9):
    for j in range(9):
        print(spot[i][j], end="")
        if((j + 1) % 3 == 0):
            print(end=" ")
    if ((i + 1) % 3 == 0):
        print()
    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:]
#print(l)
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:]
#print(*l,sep='\n')

for i in range(3):
    for j in range(3):
        print(l[i][0][j],l[i][1][j],l[i][2][j])
    print("")

from math import ceil
s = [list(input().replace(' ', '')) for i in range(3)]
input()
s += [list(input().replace(' ', '')) for i in range(3)]
input()
s += [list(input().replace(' ', '')) for i in range(3)]
y, x = [int(k) for k in input().split(' ') if k]
yb, xb = ceil(y / 3), ceil(x / 3)
y -= (yb - 1) * 3 + 1
x -= (xb - 1) * 3 + 1
y *= 3
x *= 3
found = 0
for dy in range(3):
    for dx in range(3):
        if s[y + dy][x + dx] == '.':
            found = 1
            s[y + dy][x + dx] = '!'
if not found:
    for y in range(9):
        for x in range(9):
            if s[y][x] == '.':
                s[y][x] = '!'
for y in range(3):
    for x in range(3):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(3, 6):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(6, 9):
        print(s[y][x], end='')
    print(' ')
print()
for y in range(3, 6):
    for x in range(3):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(3, 6):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(6, 9):
        print(s[y][x], end='')
    print(' ')
print()
for y in range(6, 9):
    for x in range(3):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(3, 6):
        print(s[y][x], end='')
    print(' ', end='')
    for x in range(6, 9):
        print(s[y][x], end='')
    print(' ')

from math import ceil

table = []
for i in range(3):
	var = []
	for _ in range(3):
		var.append(input().split())
	table.append(var)
	if i != 2:
		input()
y, x = [int(x) for x in input().split()]
x1 = (x % 3) - 1
y1 = (y % 3) - 1
for i in range(3):
	if '.' in table[y1][i][x1]:
		for j in range(3):
			table[y1][j][x1] = table[y1][j][x1].replace('.', '!')
		break
else:
	for i in range(3):
		for j in range(3):
			for k in range(3):
				table[i][j][k] = table[i][j][k].replace('.', '!')
for x in table:
	for y in x:
		print(*y)
	print()

# python3
# utf-8

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)
    # rows += 1
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
# print(row, col)
# print(glob_row, glob_col)
# print(next_glob_row, next_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
        # print(curr_row, curr_col)
        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('')

grid = [[[] for x in range(3)] for x in range(3)]
for j in range(3):
  for i in range(3):
    row = raw_input().split()
    for k in range(3):
      grid[j][k].append(list(row[k]))
  if j != 2:
    raw_input()
a,b = map(int,raw_input().split())
if a%3==0: #bottom row
  if b%3==0: #rightmost row
    cell = 8
  elif b%3==2:
    cell = 7
  else:
    cell = 6
elif a%3==2:
  if b%3 == 0:
    cell = 5
  elif b%3 == 2:
    cell = 4
  else:
    cell = 3
else:
  if b%3==0:
    cell = 2
  elif b%3==2:
    cell = 1
  else:
    cell = 0
valid = False
for i in range(3):
  for j in range(3):
    if grid[cell/3][cell%3][i][j] == '.':
      valid = True
      grid[cell/3][cell%3][i][j] = '!'
if not valid:
  for i in range(3):
    for j in range(3):
      for k in range(3):
        for l in range(3):
          if grid[i][j][k][l] == '.':
            grid[i][j][k][l] = '!'
for i in range(3):
  for j in range(3):
    print "".join(grid[i][0][j])+" "+"".join(grid[i][1][j])+" "+"".join(grid[i][2][j])
  if i != 2:
    print ""

import sys

#f = open('input', 'r')
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()

#http://codeforces.com/problemset/problem/907/B
#solved

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])

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('')

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])

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])

# print(*fields, sep='\n')

x_y = [int(i) - 1 for i in input().split()]

# print(*table, sep='\n')

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)

# print(*positions, sep='\n')

for order_num, candidate in enumerate(positions):
    # print(x_y)
    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]

# print(*fields, sep='\n')

for row in range(0, 7, 3):
    for column in range(3):
        for r in range(row, row + 3):
            # print(r, column)
            print(*fields[r][column], sep='', end=' ')
        print()
    print()

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

rows = []
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))
raw_input()
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))
raw_input()
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))
rows.append("".join(raw_input().split()))

row, col = map(int, raw_input().split())

qrtr = ((row - 1) % 3, (col - 1) % 3)

rows = map(list, rows)
has_empty = False

for i in range(3):
    for j in range(3):
        if rows[3 * qrtr[0] + i][3 * qrtr[1] + j] == ".":
            has_empty = True
            rows[3 * qrtr[0] + i][3 * qrtr[1] + j] = "!"

if not has_empty:
    for i in range(len(rows)):
        rows[i] = map(lambda c: "!" if c == "." else c, rows[i])

rows = ["".join(r) for r in rows]
i = 0
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1
print rows[i][:3], rows[i][3:6], rows[i][6:]
i += 1

import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
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)]
#MOD = 1000000000 + 7
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])

#print(A)
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

#print(i,j)
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
#print(a,c)

k1 = i -a
k2 = j -c
#print(k1,k2)

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()

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(' ')

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
else:
    if 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))
# print(x,y)

'''
st = '1.1 1.2 1.3\n' \
     '2.1 2.2 2.3\n' \
     '3.1 3.2 3.3\n' \
     '\n' \
     '4.1 4.2 4.3\n' \
     '5.1 5.2 5.3\n' \
     '6.1 6.2 6.3\n' \
     '\n' \
     '721 752 783\n' \
     '821 852 883\n' \
     '921 952 983\n'
xlast = 3
ylast = 6
'''

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() + ' '
#print(st)
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('free=', free)
print_pole()

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))

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])))

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()

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("")

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

if __name__ == "__main__":
    Solution = CodeforcesTask907BSolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())

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()

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()

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 = [None]*3

for i in range(3):
  if i != 0:
    input() # empty
  field[i] = line = []
  for j in range(3):
    line.append(input().replace(' ', ''))
x, y = map(lambda x: (int(x)-1)%3, input().split(' '))

#for i in field: print(i)
#print('done')

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)

'''
.!. ... ...
... ... .z.
... ... ...

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

..x ... .e.
.x. .s. .f.
x.. ... .c.
6 4

'''

field = [input().split() for _ in range(11)]
del field[7]
del field[3]

last_y,last_x = [int(i)-1 for i in input().split()]
f_x = last_x % 3
f_y = last_y % 3

for i in range(3):
    if '.' in field[f_y*3+i][f_x]:
        for y in range(3):
            field[f_y*3+y][f_x] = field[f_y*3+y][f_x].replace('.','!')
        break;
else:
    for y in range(9):
        for x in range(3):
            field[y][x] = field[y][x].replace('.','!')

print(str([str(s)[2:-2].replace("', '", ' ') for s in field])[2:-2].replace("', '",'\n'))

mass = []
for i in range(11) :
    a = list(input())
    if i != 3 and i != 7 :
        a.pop(3)
        a.pop(6)
        mass.append(a)

x, y = map(int, input().split())
x -= 1
y -= 1

n = 0
for i in range(x % 3 * 3, x % 3 * 3 + 3) :
    for j in range(y % 3 * 3, y % 3 * 3 + 3) :
        if mass[i][j] == '.' :
            mass[i][j] = '!'
            n += 1

if n == 0 :
    for i in range(9) :
        for j in range(9) :
            if mass[i][j] == '.' :
                mass[i][j] = '!'

for i in range(9) :
    mass[i].insert(3, ' ')
    mass[i].insert(7, ' ')
    if i == 3 or i == 6 :
        print()
    for j in range(11) :
        print(mass[i][j], end = ' ')
    print()

s = [[] * 9 for i in range(9)]

k = -1

for i in range(11):
    g = input().replace(' ', '')
    if g != '':
        k += 1
        for j in g:
            if j != '':
                s[k].append(j)

x, y = map(int, input().split())

x1, y1 = x % 3, y % 3

j = ''

l = 0

for i in range((x1 - 1) * 3, x1 * 3):
    for r in range((y1 - 1) * 3, y1 * 3):
        j += s[i][r]
    l += 1

if j.count('.') == 0:
    for i in s:
        o = 0
        for h in i:
            if o % 3 == 0 and o != 0:
                print(' ', end='')
            if h == '.':
                print('!', end='')
            else:
                print(h, end='')
            o += 1
        print('\n')
else:
    for i in range((x1 - 1) * 3, x1 * 3):
        for r in range((y1 - 1) * 3, y1 * 3):
            if s[i][r] == '.':
                s[i][r] = '!'

    for i in s:
        o = 0
        for h in i:
            if o % 3 == 0 and o != 0:
                print(' ', end='')
            print(h, end='')
            o += 1
        print('\n')

from pprint import pprint

flag = False
field = [[[], [], []],
         [[], [], []],
         [[], [], []]]
for i in range(3):
    a, b, c = input().split()
    field[0][0].append(list(a))
    field[0][1].append(list(b))
    field[0][2].append(list(c))
input()
for i in range(3):
    a, b, c = input().split()
    field[1][0].append(list(a))
    field[1][1].append(list(b))
    field[1][2].append(list(c))
input()
for i in range(3):
    a, b, c = input().split()
    field[2][0].append(list(a))
    field[2][1].append(list(b))
    field[2][2].append(list(c))

y, x = map(int, input().split())

if 0 < y < 4:
    new = field[0]

elif 3 < y < 7:
    new = field[1]

else:
    new = field[2]

if 0 < x < 4:
    new = new[0]

elif 3 < x < 7:
    new = new[1]

else:
    new = new[2]

new_y, new_x = (y - 1) % 3, (x - 1) % 3
curr = field[new_y][new_x]
if '.' in ''.join([''.join(i) for i in curr]):
    flag = True
k = 0
b = 0
if not flag:
    for line in field:
        for i in range(3):
            for ind3, elem in enumerate(line):
                s = ''.join(elem[k]).replace('.', '!')
                if ind3 == len(line) - 1:
                    print(s, end='')
                else:
                    print(s, end=' ')
            print()
            k += 1
        k = 0
else:
    for ind, line in enumerate(field):
        for i in range(3):
            for ind2, elem in enumerate(line):
                if ind == new_y and ind2 == new_x:
                    s = ''.join(elem[k]).replace('.', '!')
                else:
                    s = ''.join(elem[k])

                if ind2 == len(line) - 1:
                    print(s, end='')
                else:
                    print(s, end=' ')
            print()
            k += 1
        k = 0

def Y():
    x,y = x0,y0
    while x > 3:
        x -= 3
    while y > 3:
        y -=3
    y,x = x-1,y-1
    if now == 1:
        x,y = x,y
    if now == 2:
         x,y = x, y + 3
    if now == 3:
         x,y = x, y + 6
    if now == 4:
         x,y = x + 3, y
    if now == 5:
         x,y = x + 3, y + 3
    if now == 6:
         x,y = x + 3, y + 6
    if now == 7:
         x,y = x + 6, y
    if now == 8:
         x,y = x + 6, y + 3
    if now == 9:
         x,y = x + 6, y + 6
    return [x,y]

def coun(x1,x2,y1,y2):
    ans = 0
    for i in range(x1,x2 + 1):
        for j in range(y1,y2 + 1):
            if a[i][j] == '.':
                ans += 1
    return ans

def F(xc,yc):
    x,y = xc,yc
    while x > 3:
        x -= 3
    while y > 3:
        y -=3
    y,x = x-1,y-1
    if x == 0 and y == 0:
        return 1
    if x == 0 and y == 1:
        return 4
    if x == 0 and y == 2:
        return 7
    if x == 1 and y == 0:
        return 2
    if x == 1 and y == 1:
        return 5
    if x == 1 and y == 2:
        return 8
    if x == 2 and y == 0:
        return 3
    if x == 2 and y == 1:
        return 6
    if x == 2 and y == 2:
        return 9

a = []
for i in range(11):
    b = input()
    if i != 3 and i != 7:
        a.append([b[0],b[1],b[2],b[4],b[5],b[6],b[8],b[9],b[10]])

x0, y0 = map(int, input().split())

now = F(x0,y0)

if now == 1:
    kek = [0,2,0,2]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 2:
    kek = [0,2,3,5]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 3:
    kek = [0,2,6,8]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 4:
    kek = [3,5,0,2]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 5:
    kek = [3,5,3,5]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 6:
    kek = [3,5,6,8]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 7:
    kek = [6,8,0,2]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 8:
    kek = [6,8,3,5]
    toch = coun(kek[0],kek[1],kek[2],kek[3])
if now == 9:
    kek = [6,8,6,8]
    toch = coun(kek[0],kek[1],kek[2],kek[3])

tow = Y()

if toch == 0 or a[tow[0]][tow[1]] != '.':
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.':
                print('!',end ='')
            else:
                print(a[i][j], end='')
            if j == 2 or j == 5 :
                print(' ',end='')
        print()
        if i == 2 or i == 5:
            print()

else:
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.' and  i >= kek[0] and i <= kek[1] and j >= kek[2] and j <=kek[3] :
                print('!',end ='')
            else:
                print(a[i][j], end='')
            if j == 2 or j == 5 :
                print(' ',end='')
        print()
        if i == 2 or i == 5:
            print()

A=[]
for i in range(11):
    A.append(input())
B=[]
for i in A:
    if i!='':
        B.append([i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10],])
print(B)
xd=list(map(int,input().split()))
x=xd[0]
y=xd[1]
changed=False
if x in [1,4,7]:
    if y in [1,4,7]:
        for i in range(3):
            for j in range(3):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    elif y in [2,5,8]:
        for i in range(3):
            for j in range(3,6):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    else:
        for i in range(3):
            for j in range(6,9):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
elif x in [2,5,8]:
    if y in [1,4,7]:
        for i in range(3,6):
            for j in range(3):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    elif y in [2,5,8]:
        for i in range(3,6):
            for j in range(3,6):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    else:
        for i in range(3,6):
            for j in range(6,9):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
else:
    if y in [1,4,7]:
        for i in range(6,9):
            for j in range(3):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    elif y in [2,5,8]:
        for i in range(6,9):
            for j in range(3,6):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
    else:
        for i in range(6,9):
            for j in range(6,9):
                if B[i][j]=='.':
                    B[i][j]='!'
                    changed=True
if not changed:
    for i in range(9):
        for j in range(9):
            if B[i][j]=='.':
                B[i][j]='!'
for i in range(9):
    if i==3 or i==6:
        print('')
    print(B[i][0]+B[i][1]+B[i][2]+' '+B[i][3]+B[i][4]+B[i][5]+' '+B[i][6]+B[i][7]+B[i][8])

a=[]
for i in range(11):
    b=[]
    s=input().split()
    if not s:
        continue
    for k in s:
        for i in range(3):
            b.append(k[i])
    a.append(b)
x,y=map(int,input().split())
x=(x-1)%3
y=(y-1)%3
fl=False
for i in range(x,x+3):
    for j in range(y,y+3):
        if a[i][j]=='.':
            a[i][j]='!'
            fl=True
if not fl:
    for i in range(9):
        for j in range(9):
            if a[i][j]=='.':
                a[i][j]='!'
for i in range(3):
    for j in range(3):
        for k in range(3):
            for c in range(3):
                print(a[i*3+j][k*3+c],end='')
            print(' ',end='')
        print()
    print()

g = [[],[],[],[],[],[],[],[],[]]
for i in range(3):
    s = input().split()
    g[0].append((' '.join(j for j in s[0])).split())
    g[1].append((' '.join(j for j in s[1])).split())
    g[2].append((' '.join(j for j in s[2])).split())
la = input()
for i in range(3):
    s = input().split()
    g[3].append((' '.join(j for j in s[0])).split())
    g[4].append((' '.join(j for j in s[1])).split())
    g[5].append((' '.join(j for j in s[2])).split())
la = input()
for i in range(3):
    s = input().split()
    g[6].append((' '.join(j for j in s[0])).split())
    g[7].append((' '.join(j for j in s[1])).split())
    g[8].append((' '.join(j for j in s[2])).split())
z = input().split()
z[0] = int(z[0])
z[1] = int(z[1])
z[0]%=3
z[1]%=3
x = z[0]
y = z[1]
ref  = 0
if x==1 and y == 1:
    ref  = 0
if x==1 and y == 2:
    ref  = 1
if x==1 and y == 0:
    ref  = 2

if x==2 and y == 1:
    ref  = 3
if x==2 and y == 2:
    ref  = 4
if x==2 and y == 0:
    ref  = 5

if x==0 and y == 1:
    ref  = 6
if x==0 and y == 2:
    ref  = 7
if x==0 and y == 0:
    ref  = 8
def check(g):
    for i in g:
        for j in i:
            if j=='.':
                return True
    return False
if check(g[ref]):
    for i in range(3):
        for j in range(3):
            if(g[ref][i][j]=='.'):
                g[ref][i][j]= '!'
else:
    for i in range(9):
        for j in range(3):
            for k in range(3):
                if(g[i][j][k]=='.'):
                    g[i][j][k] = '!'

ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(3,6,1):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)
ans = ''
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][0][j]
    ans+=' '
print(ans)
ans = ''
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][1][j]
    ans+=' '
print(ans)
ans = ''
for i in range(6,9,1):
    for j in range(3):
        ans+=g[i][2][j]
    ans+=' '
print(ans)

a = [[None] * 9 for i in range(9)]

for k in range(3):
    for i in range(3):
        sl = input().split()
        for j in range(3):
            for l in range(3):
                a[k * 3 + i][j * 3 + l] = sl[j][l]
    if k != 2:
        tmp = input()

x, y = map(int, input().split())
x -= 1
y -= 1

bx = x % 3
by = y % 3

ok = False
for i in range(bx * 3, bx * 3 + 3):
    for j in range(by * 3, by * 3 + 3):
        if a[i][j] == '.':
            ok = True
            a[i][j] = '!'
if not ok:
    for i in range(9):
        for j in range(9):
            if a[i][j] == '.':
                a[i][j] = '!'

for k in range(3):
    for i in range(3):
        for j in range(3):
            for l in range(3):
                print(a[k * 3 + i][j * 3 + l], end="")
            print(" ", end="")
        print()

table = []

for i in range(2):
    for j in range(3):
        table.append(list(map(list, input().split())))
    input()

for i in range(3):
    table.append(list(map(list, input().split())))

y, x = map(int, input().split())

place = [(x-1)%3, (y-1)%3]

print(place)
bool1 = True

for i in range(place[1]*3, place[1]*3+3):
    for j in range(len(table[i][place[0]])):
        if '.' == table[i][place[0]][j]:
            table[i][place[0]][j] = '!'
            bool1 = False

if bool1:
    for i in range(len(table)):
        for j in range(len(table[i])):
            for k in range(len(table[i][j])):
                if table[i][j][k] == '.' and (y-1 != i or x-1 // 3 != j or x-1 % 3 != k):
                    table[i][j][k] = '!'

for i in range(len(table)):
    for j in table[i]:
        for k in j:
            print(k, end='')
        print(end=' ')
    print()
    if (i+1) % 3 == 0:
        print()

A = []
for i in range(11):
    s = input()
    s = s.replace(" ", "")
    if s == "":
        continue
    A.append(list(s))
x, y = map(int, input().split())
x = (x-1) % 3
y = (y-1) % 3
print(x, y)
rep = 0
for i in range(3):
    for j in range(3):
        if(A[3 * x + i][3 * y + j] == "."):
            A[3 * x + i][3 * y + j] = "!"
            rep += 1
if(rep == 0):
    for i in range(9):
        for j in range(9):
            if A[i][j] == ".":
                A[i][j] = "!"
for i in range(9):
    A[i] = A[i][0] + A[i][1] + A[i][2] + ' ' + A[i][3]  + A[i][4]  + A[i][5] + ' ' + A[i][6]  + A[i][7]  + A[i][8]

# for i in range(9):
#     for j in range(11):
#         print(A[i][j], end = '')
#     print()

for i in range(0,3):
    print(A[i])
print()

for i in range(3,6):
    print(A[i])
print()

for i in range(6,9):
    print(A[i])
print()

matrix = []
matrix_end = []
arr = []
for i in range(11):
    n = input()
    if n != "":
        for j in range(11):
            if n[j] != " ":
                arr.append(n[j])
        matrix.append(arr)
        arr = []
x,y = map(int,input().split())
x_b = (x-1) % 3
y_b = (y-1) % 3
ch = True
for i in range(3*x_b, 3*x_b+3):
    for j in range(3*y_b, 3*y_b+3):
        if matrix[i][j] == ".":
            ch = False
if ch:
    for i in range(9):
        for j in range(9):
            if matrix[i][j] == ".":
                matrix[i][j] = "!"
else:
    for i in range(3*x_b, 3*x_b + 3):
        for j in range(3*y_b, 3*y_b + 3):
            if matrix[i][j] == ".":
                matrix[i][j] = "!"
s = ""
cnt_x = 0
cnt_y = 0
for j in range(11):
    if j == 3 or j == 7:
        s = "\n"
        cnt_y +=1
    else:
        for i in range(11):
            if i == 3 or i == 7:
                s+=" "
                cnt_x+=1
            else:
                s+=matrix[j-cnt_y][i-cnt_x]
    cnt_x = 0
    print(s)
    s = ""

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

import sys

from itertools import islice

def read_field():
    return filter(lambda x: x, [
        list(line.rstrip().replace(' ', ''))
        for line in map(lambda _: sys.stdin.readline(), range(11))
    ])

class SmallFiled:
    def __init__(self, f, x, y):
        self.x = x
        self.y = y
        self.f = f

    def coord(self, x, y):
        return 3 * self.x + x, 3 * self.y + y

    def __call__(self, x, y):
        return self.get(x, y)

    def get(self, x, y):
        i, j = self.coord(x, y)
        return self.f[i][j]

    def set(self, x, y, v):
        i, j = self.coord(x, y)
        self.f[i][j] = v

def is_all_filled(sf):
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                return False
    return True

def mark_all_empty(bf):
    for i in range(9):
        for j in range(9):
            if bf[i][j] == '.':
                bf[i][j] = '!'
    return bf

def find_move(fs, bf, x, y, xx, yy):
    sf = fs[x][y]
    x, y = sf.coord(0, 0)
    sf = fs[xx - x][yy - y]
    if is_all_filled(sf):
        return mark_all_empty(bf)
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                sf.set(i, j, '!')
    return bf

def print_filed(bf):
    for i in range(9):
        for j in range(9):
            print bf[i][j],
            if j == 2 or j == 5:
                print ' ',
        print
        if i == 2 or i == 5:
            print

big_field = read_field()
fields = [
    [
        SmallFiled(big_field, i, j)
        for j in range(3)
    ]
    for i in range(3)
]

# from pprint import pprint
# pprint(big_field)
y, x = map(int, sys.stdin.readline().split())
x -= 1
y -= 1

#fields[2][1].set(0, 0, '?')

res = find_move(fields, big_field, x / 3, y / 3, x, y)
print_filed(res)

import sys

from itertools import islice

def read_field():
    return filter(lambda x: x, [
        list(line.rstrip().replace(' ', ''))
        for line in map(lambda _: sys.stdin.readline(), range(11))
    ])

class SmallFiled:
    def __init__(self, f, x, y):
        self.x = x
        self.y = y
        self.f = f

    def coord(self, x, y):
        return 3 * self.x + x, 3 * self.y + y

    def __call__(self, x, y):
        return self.get(x, y)

    def get(self, x, y):
        i, j = self.coord(x, y)
        return self.f[i][j]

    def set(self, x, y, v):
        i, j = self.coord(x, y)
        self.f[i][j] = v

def is_all_filled(sf):
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                return False
    return True

def mark_all_empty(bf):
    for i in range(9):
        for j in range(9):
            if bf[i][j] == '.':
                bf[i][j] = '!'
    return bf

def find_move(fs, bf, x, y, xx, yy):
    sf = fs[x][y]
    x, y = sf.coord(0, 0)
    sf = fs[xx - x][yy - y]
    if is_all_filled(sf):
        return mark_all_empty(bf)
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                sf.set(i, j, '!')
    return bf

def print_filed(bf):
    for i in range(9):
        for j in range(9):
            print bf[i][j],
            if j == 2 or j == 5:
                print ' ',
        print
        if i == 2 or i == 5:
            print

big_field = read_field()
fields = [
    [
        SmallFiled(big_field, i, j)
        for j in range(3)
    ]
    for i in range(3)
]

# from pprint import pprint
# pprint(big_field)
x, y = map(int, sys.stdin.readline().split())
x -= 1
y -= 1

#fields[2][1].set(0, 0, '?')

res = find_move(fields, big_field, x / 3, y / 3, x, y)
print_filed(res)

import sys

from itertools import islice

def read_field():
    return filter(lambda x: x, [
        list(line.rstrip().replace(' ', ''))
        for line in map(lambda _: sys.stdin.readline(), range(11))
    ])

class SmallFiled:
    def __init__(self, f, x, y):
        self.x = x
        self.y = y
        self.f = f

    def coord(self, x, y):
        return 3 * self.x + x, 3 * self.y + y

    def __call__(self, x, y):
        return self.get(x, y)

    def get(self, x, y):
        i, j = self.coord(x, y)
        return self.f[i][j]

    def set(self, x, y, v):
        i, j = self.coord(x, y)
        self.f[i][j] = v

def is_all_filled(sf):
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                return False
    return True

def mark_all_empty(bf):
    for i in range(9):
        for j in range(9):
            if bf[i][j] == '.':
                bf[i][j] = '!'
    return bf

def find_move(fs, bf, x, y, xx, yy):
    print x, y, xx, yy
    sf = fs[x][y]
    x, y = sf.coord(0, 0)
    sf = fs[xx - x][yy - y]
    if is_all_filled(sf):
        return mark_all_empty(bf)
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                sf.set(i, j, '!')
    return bf

def print_filed(bf):
    for i in range(9):
        for j in range(9):
            print bf[i][j],
            if j == 2 or j == 5:
                print ' ',
        print
        if i == 2 or i == 5:
            print

big_field = read_field()
fields = [
    [
        SmallFiled(big_field, i, j)
        for j in range(3)
    ]
    for i in range(3)
]

# from pprint import pprint
# pprint(big_field)
y, x = map(int, sys.stdin.readline().split())
x -= 1
y -= 1

#fields[2][1].set(0, 0, '?')

res = find_move(fields, big_field, x / 3, y / 3, x, y)
print_filed(res)

import sys

from itertools import islice

def read_field():
    return filter(lambda x: x, [
        list(line.rstrip().replace(' ', ''))
        for line in map(lambda _: sys.stdin.readline(), range(11))
    ])

class SmallFiled:
    def __init__(self, f, x, y):
        self.x = x
        self.y = y
        self.f = f

    def coord(self, x, y):
        return 3 * self.x + x, 3 * self.y + y

    def __call__(self, x, y):
        return self.get(x, y)

    def get(self, x, y):
        i, j = self.coord(x, y)
        return self.f[i][j]

    def set(self, x, y, v):
        i, j = self.coord(x, y)
        self.f[i][j] = v

def is_all_filled(sf):
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                return False
    return True

def mark_all_empty(bf):
    for i in range(9):
        for j in range(9):
            if bf[i][j] == '.':
                bf[i][j] = '!'
    return bf

def find_move(fs, bf, x, y, xx, yy):
    print x, y, xx, yy
    sf = fs[x][y]
    x, y = sf.coord(0, 0)
    sf = fs[xx - x][yy - y]
    if is_all_filled(sf):
        return mark_all_empty(bf)
    for i in range(3):
        for j in range(3):
            if sf(i, j) == '.':
                sf.set(i, j, '!')
    return bf

def print_filed(bf):
    for i in range(9):
        for j in range(9):
            print bf[i][j],
            if j == 2 or j == 5:
                print ' ',
        print
        if i == 2 or i == 5:
            print

big_field = read_field()
fields = [
    [
        SmallFiled(big_field, i, j)
        for j in range(3)
    ]
    for i in range(3)
]

# from pprint import pprint
# pprint(big_field)
x, y = map(int, sys.stdin.readline().split())
x -= 1
y -= 1

#fields[2][1].set(0, 0, '?')

res = find_move(fields, big_field, x / 3, y / 3, x, y)
print_filed(res)

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
print(y%3*3,y%3*3+2)
print(x%3*3,x%3*3+2)
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()

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
print(x,y)
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()

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])
[print(*i) for i in matrix]
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()

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
	for i in range((xreg*3),((xreg+1)*(3))):
		for j in range( (yreg*3),((yreg+1)*(3)) ):
			if arr[i][j]!='.':
				flag = False
				break
	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()

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
	for i in range((xreg*3),((xreg+1)*(3))):
		for j in range( (yreg*3),((yreg+1)*(3)) ):
			if arr[i][j]!='.':
				flag = False
				break
	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==7:
			print()
		for j in range(3):
			string = ''.join(arr[i][(j*3):((j+1)*(3))])
			print(string ,end=' ')
		print()

main()

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]
print(subsquare)

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]))

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:
        print('')
    for j in range(9):
        if j % 3 == 0:
            print(' ', end='')
        if flag and a[i][j] == '.':
            print('!', end='')
        else:
            print(a[i][j], end='')
    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 += 1

Y = y % 3
if y % 3 == 0:
    Y += 1

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(3):
    for j in range(3):
        qwe.append((i * X, j * Y))
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])
        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()

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):
        print(i, j)
        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 i in range(11):
    print(''.join(l[i]))

l=[list(''.join(s.split())) for s in (input() for _ in range(11)) if s]
x,y=map(int, input().split())
x-=1
y-=1
a,b=x%3*3,y%3*3
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(9):
        for j in range(9):
            if l[i][j]=='.':
                l[i][j]='!'
for i in range(0,9,3):
    for j in range(3):
        s=''.join(l[i+j])
        print(' '.join((s[:3],s[3:6],s[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
print(firstindex, secondindex)
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 key in badook:
    print(key)

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()

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(1,4):
    tgt.append(org[3*x-i][y-1])

tmp = 0
for c in tgt:
    for k in range(3):
        if c[k] == '.':
            c[k] == '!'
            tmp += 1
if tmp != 0 :
    for q in range(1,4):
        org[3 * x - q][y - 1] = tgt[q-1]

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[0:11])
        print()
    else:
        sp = ''
        for u in range(3):
            sp += org[v][u]+' '
        print(sp[0:11])

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(1,4):
    tgt.append(org[3*x-i][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(1,4):
        org[3 * x - q][y - 1] = tgt[q-1]

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)

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(1,4):
    tgt.append(org[3*x-i][y-1])

tmp = 0
for c in tgt:
    for k in range(3):
        if c[k] == '.':
            c[k] == '!'
            tmp += 1
if tmp != 0 :
    for q in range(1,4):
        org[3 * x - q][y - 1] = tgt[q-1]

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)

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
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]=grid[3*xn+i][:3*yn+j]+"!"+grid[3*xn+i][3*yn+j+1:]
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*xn+3:
                continue
            elif grid[i][j]!=".":
                continue
            else:
                grid[i]=grid[i][:j]+"!"+grid[i][j+1:]
for i in range(9):
    if i%3==0 and i!=0:
        print()
    print(grid[i][:3]+" "+grid[i][3:6]+" "+grid[i][6:])

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*xn+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:])

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
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*xn+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:])

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:])]))

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(9):
        for j in range(3):
            for v in range(3):
                if(mtrx[i][j*3+v] == 0):
                    res += '.'
                elif(mtrx[i][j*3+v] == 1):
                    res += 'x'
                elif(mtrx[i][j*3+v] == 2):
                    res += 'o'
                else:
                    res += '!'
            res += ' '
        res += '\n'

    print(res)
main()

l=[]
xnum=0
for i in range(11):
      l.append(input())
      if "x" in l[i]:
            xnum+=l[i].count("x")
            posx=l[i].index("x")
            posy=i
x,y=map(int,input().split())
if xnum==1:
      if posx<4:
            x=posx+1
      elif posx>6:
            x=posx-1
      else:
            x=posx
      if posy<4:
            y=posy+1
      elif posy>6:
            y=posy-1
      else:
            y=posy
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(p2,p2+3):
      for j in range(p,p+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>=p2 and i < p2+3 and j >= p and j < p+3:
                        if l[i][j]=='.':
                              print("!",end="")
                        else:
                              print(l[i][j],end="")
                  else:
                        print(l[i][j],end="")
            print()

#http://codeforces.com/problemset/problem/907/B
#solved

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[1] + ninght[2])
fild.append(seventh[0] + eight[1] + ninght[2])
fild.append(seventh[0] + eight[1] + 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])

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[i][k] += [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)
    # print(l[xx][yy][i])
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()