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

The game is played on the following field. [Image] 

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

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

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


-----Input-----

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

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

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


-----Output-----

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


-----Examples-----
Input
... ... ...
... ... ...
... ... ...

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

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

Output
... ... ... 
... ... ... 
... ... ... 

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

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


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

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

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

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

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

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


Input
o.. ... ...
... ... ...
... ... ...

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

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

Output
o!! !!! !!! 
!!! !!! !!! 
!!! !!! !!! 

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

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




-----Note-----

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

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

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

Difficulty: interview

Starter code:

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


#!/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 = list(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()



def __starting_point():
	main()

__starting_point()

a = [[] for i in range(10)]
pp = -1
for i in range(11):
    b = input()
    b.split()
    if i == 3 or i == 7:
        continue
    pp += 1
    for j in range(len(b)):
        if b[j] == ' ':
            continue
        a[pp].append(b[j])
x, y = map(int, input().split())
x %= 3
y %= 3
if x == 0:
    x0 = 6
if x == 1:
    x0 = 0
if x == 2:
    x0 = 3
    
if y == 0:
    y0 = 6
if y == 1:
    y0 = 0
if y == 2:
    y0 = 3
ans = False
for i in range(x0, x0 + 3):
    for j in range(y0, y0 + 3):
        if a[i][j] == '.':
            ans = True
            a[i][j] = '!'
if ans == False:
    for i in range(0, 9):
        for j in range(0, 9):
            if a[i][j] == '.':
                a[i][j] = '!'
                
for i in range(0, 9):
    if i == 3 or i == 6:
        print()
    for j in range(0, 9):
        if j == 3 or j == 6:
            print(end = " ")
        print(a[i][j], end = "")
    print()

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

a = [0] * 9


def check(x, y):
    nonlocal a
    for i in range(3):
        for j in range(3):
            if (a[i + x * 3][j + y * 3] == '.'):
                return True
    return False

def yall():
    nonlocal a
    for i in range(9):
        for j in range(9):
            if (a[i][j] == '.'):
                a[i][j] = '!'
                
def nall(x, y):
    nonlocal a
    for i in range(3):
        for j in range(3):
            if (a[i + x * 3][j + y * 3] == '.'):
                a[i + x * 3][j + y * 3] = '!'

for i in range(9):
    b = [j for j in input().split()]
    a[i] = [b[k][j] for k in range(3) for j in range(3)]
    if (i % 3 == 2 and i != 8):
        input()

x, y = [int(i) for i in input().split()]
x1 = (x-1) % 3
y1 = (y-1) % 3

if check(x1, y1):
    nall(x1, y1)
else:
    yall()
    
for i in range(9):
    for j in range(9):
        print(a[i][j], end = '')
        if (j % 3 == 2):
            print(" ", end = '')
    if (i % 3 == 2):
        print()
    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()
    



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


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


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


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

for i in range(9) :
    s = input().split();
    
    if (s == []) :
        s = input().split();
    
    for j in range(3) :
        field[i][3 * j] = s[j][0];
        field[i][3 * j + 1] = s[j][1];
        field[i][3 * j + 2] = s[j][2];
    
x, y = map(int, input().split());
x -= 1;
y -= 1;

ix, iy = x % 3, y % 3;

if (ix == 0 and iy == 0) :
    fl = 0;
    
    for i in range(3) :
        for j in range(3) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';

if (ix == 0 and iy == 1) :
    fl = 0;
    
    for i in range(3) :
        for j in range(3, 6) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';
                    
if (ix == 0 and iy == 2) :
    fl = 0;
    
    for i in range(3) :
        for j in range(6, 9) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';
                    
                    
if (ix == 1 and iy == 0) :
    fl = 0;
    
    for i in range(3, 6) :
        for j in range(3) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';

if (ix == 1 and iy == 1) :
    fl = 0;
    
    for i in range(3, 6) :
        for j in range(3, 6) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';
                    
if (ix == 1 and iy == 2) :
    fl = 0;
    
    for i in range(3, 6) :
        for j in range(6, 9) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';
                    

if (ix == 2 and iy == 0) :
    fl = 0;
    
    for i in range(6, 9) :
        for j in range(3) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';

if (ix == 2 and iy == 1) :
    fl = 0;
    
    for i in range(6, 9) :
        for j in range(3, 6) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';
                    
if (ix == 2 and iy == 2) :
    fl = 0;
    
    for i in range(6, 9) :
        for j in range(6, 9) :
            if (field[i][j] == '.') :
                fl = 1;
                field[i][j] = '!';
    
    if (not fl) :
        for i in range(9) :
            for j in range(9) :
                if (field[i][j] == '.') :
                    field[i][j] = '!';


for i in range(9) :
    if (i % 3 == 0 and i != 0) :
        print();
        
    for j in range(9) :
        if (j % 3 == 0 and j != 0) :
            print(" ", end = "");
        print(field[i][j], end = "");
    
    print();


k=[]
for i in range(11):
    a=input()
    if i!=3 and i!=7:
        k.append(a[0]+a[1]+a[2]+a[4]+a[5]+a[6]+a[8]+a[9]+a[10]+' ')
a,b=map(int,input().split())
a-=1
b-=1
x=a%3
y=b%3
r=1
for i in range(3):
    s=k[x*3+i]
    for j in range(3):
        if s[y*3+j]=='.':
            s=s[:y*3+j]+"!"+s[y*3+j+1:]
            r=0
    k[x*3+i]=s
if r==1:
    for i in range(9):
        s=k[i]
        for j in range(9):
            if s[j]=='.':
                s=s[:j]+"!"+s[j+1:]
        k[i]=s
for i in range(9):
    for j in range(9):
        print(k[i][j],end='')
        if j==2 or j==5:
            print(' ',end='')
    print('')
    if i==2 or i==5:
        print('')


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


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


matrix = []
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
input()
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
input()
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
matrix.append(''.join(input().split()))
x, y = list(map(int, input().split()))
x -= 1
y -= 1
flag = True
for i in range(x % 3 * 3, x % 3 * 3 + 3):
    for j in range(y % 3 * 3, y % 3 * 3 + 3):
        if matrix[i][j] == '.':
            flag = False
            matrix[i] = matrix[i][:j] + '!' + matrix[i][j + 1:]
if flag:
    for i in range(9):
        for j in range(9):
            if matrix[i][j] == '.':
                matrix[i] = matrix[i][:j] + '!' + matrix[i][j + 1:]
for i in range(3):
    print(matrix[i][:3], matrix[i][3:6], matrix[i][6:9])
print()
for i in range(3, 6):
    print(matrix[i][:3], matrix[i][3:6], matrix[i][6:9])
print()
for i in range(6, 9):
    print(matrix[i][:3], matrix[i][3:6], matrix[i][6:9])


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*3,x*3+3):
    for j in range(y*3,y*3+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()


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


field = []
for i in range(3):
    a1, a2, a3 = [], [], []
    for j in range(3):
        s = list(input())
        a1.append(s[:3])
        a2.append(s[4:7])
        a3.append(s[8:11])
    if i != 2:
        s = input()
    row = [a1, a2, a3]
    field.append(row)
x, y = map(int, input().split())
x -= 1
y -= 1
x, y = x % 3, y % 3
isset = False
for i in range(3):
    for j in range(3):
        if field[x][y][i][j] == '.':
            isset = True
            field[x][y][i][j] = '!'
if not isset:
    for x in range(3):
        for y in range(3):
            for i in range(3):
                for j in range(3):
                    if field[x][y][i][j] == '.':
                        field[x][y][i][j] = '!'
for i in range(3):
    for j in range(3):
        for k in range(3): 
            print(*field[i][k][j], sep='', end=' ')
        print()
    print()



arr = [[] for i in range(9)]
for i in range(3):
    q = list(input().split())
    arr[0] += q[0]
    arr[1] += q[1]
    arr[2] += q[2]
q = input()
for i in range(3):
    q = list(input().split())
    arr[3] += q[0]
    arr[4] += q[1]
    arr[5] += q[2]
q = input()
for i in range(3):
    q = list(input().split())
    arr[6] += q[0]
    arr[7] += q[1]
    arr[8] += q[2]
x, y = list(map(int, input().split()))
x %= 3
y %= 3
if x == 1:
    if y == 1:
        pos = 0
    elif y == 2:
        pos = 1
    else:
        pos = 2
elif x == 2:
    if y == 1:
        pos = 3
    elif y == 2:
        pos = 4
    else:
        pos = 5
else:
    if y == 1:
        pos = 6
    elif y == 2:
        pos = 7
    else:
        pos = 8
if '.' in arr[pos]:
    for i in range(9):
        if arr[pos][i] == '.':
            arr[pos][i] = '!'
else:
    for i in range(9):
        for j in range(9):
            if arr[i][j] == '.':
                arr[i][j] = '!'

ans = []
for i in range(3):
    q = ''
    for j in range(3):
        for l in range(3):
            q += arr[j][i * 3 + l]
        q += ' '
    ans.append(q)
ans.append(' ')
for i in range(3):
    q = ''
    for j in range(3):
        for l in range(3):
            q += arr[3 + j][i * 3 + l]
        q += ' '
    ans.append(q)
ans.append(' ')
for i in range(3):
    q = ''
    for j in range(3):
        for l in range(3):
            q += arr[6 + j][i * 3 + l]
        q += ' '
    ans.append(q)
for i in range(11):
    print(ans[i])









a=[]
for i in range(0,3):
    a.append(input().split())
s=input() 
for i in range(0,3):
    a.append(input().split())
d=input()
for i in range(0,3):
    a.append(input().split())
q,w=list(map(int,input().split()))
z=q%3-1
if z==-1:
    z=2
x=w%3-1
if x==-1:
    x=2
z=z*3
b=True
for i in range(z,z+3):
    if a[i][x].count('.')!=0:
        b=False
        a[i][x]=a[i][x].replace('.','!')
if b:
    for i in range(0,9):
        for j in range(0,3):
            a[i][j]=a[i][j].replace('.','!')
for i in range(0,3):
    print(' '.join(a[i]))
print()
for i in range(3,6):
    print(' '.join(a[i]))
print()
for i in range(6,9):
    print(' '.join(a[i]))


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


def prnt(p):
    for i in p:
        for i3 in range(3):
            for i2 in i:
                for i4 in i2[i3]:
                    print(i4, end="")
                print(" ", end="")
            print()
        print()


p = []
for y1 in range(3):
    p.append([[], [], []])
    for y2 in range(3):
        s = input()
        if not s:
            s = input()
        s = s.split()
        for i in range(3):
            p[y1][i].append(list(s[i]))

crds = list(map(int, input().split()))
crds[0] -= 1
crds[1] -= 1

x1 = crds[0]//3
y1 = crds[1]//3
y2 = crds[0]%3
x2 = crds[1]%3

have_space = False
for i in p[y2][x2]:
    for i2 in i:
        if i2 == ".":
            have_space = True
            break

if have_space:
    for i in range(len(p[y2][x2])):
        for i2 in range(len(p[y2][x2][i])):
            if p[y2][x2][i][i2] == ".":
                p[y2][x2][i][i2] = "!"
else:
    for i1 in range(3):
        for i2 in range(3):
            for i3 in range(3):
                for i4 in range(3):
                    if p[i1][i2][i3][i4] == ".":
                        p[i1][i2][i3][i4] = "!"

prnt(p)


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)
        
            
            
        


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)

k = [[] for i in range(9)]
p = 0
r = 0
for i in range(11):
  b = input()
  b = b[:3] + b[4:7] + b[8:11]
  if b != '':
    k[i - p].append(b)
  else:
    p += 1
a, b = map(int, input().split())
a -= 1
b -= 1
for i in range(3 * (a % 3), 3 * (a % 3) + 3):
  for j in range(3 * (b % 3), 3 * (b % 3) + 3):
    if k[i][0][j] != 'o' and k[i][0][j] != 'x':
      k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]
      r = 1
if r == 0:
  for i in range(9):
    for j in range(9):
      if k[i][0][j] != 'o' and k[i][0][j] != 'x':
        k[i][0] = k[i][0][:j] + '!' + k[i][0][j + 1:]
for i in range(len(k)):
  for j in range(len(k[i][0])):
    print(k[i][0][j], end = '')
    if j == 2 or j == 5:
      print(' ', end = '')
  print(' ')
  if i == 2 or i == 5:
    print(' ')