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.  Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl, yl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl, yl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules.

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

NoteIn 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.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
      for j:=1 to 11 do
      read(a[i,j]);
    end;
    readln;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      if i mod 4<>0 then
      begin
        for j:=1 to 11 do
        if a[i,j]='.' then write('!') else
        write(a[i,j]);
      end;
      writeln;
    end;
    exit;
  end;
  for i:=1 to 11 do
    begin
      if i mod 4<>0 then
      begin
        for j:=1 to 11 do
        write(a[i,j]);
      end;
      writeln;
    end;
end.

var	s:array[1..9] of string;
	i,j,x,y,x1,y1,count:longint;
	t:string;
begin
	for i:=1 to 8 do
	begin
		readln(t);
		delete(t,4,1);
		delete(t,7,1);
		s[i]:=t;
		if i mod 3 = 0 then readln(t);
	end;
	readln(t);
	delete(t,4,1);
	delete(t,7,1);
	s[9]:=t;
	readln(x,y);
	x1:=(x-1) mod 3 + 1;
	y1:=(y-1) mod 3 + 1;

	count:=0;
	for i:=(x1-1)*3 + 1 to x1*3 do
		for j:= (y1-1)*3 + 1 to y1*3 do
			if (s[i][j]='.')then inc(count);
	if count>0 then
	begin
		for i:=(x1-1)*3 + 1 to x1*3 do
			for j:= (y1-1)*3 + 1 to y1*3 do
				if (s[i][j]='.') then
				begin
					delete(s[i],j,1);
					insert('!',s[i],j);
				end;
	end
	else
	begin
		for i:=1 to 9 do
			for j:=1 to 9 do
				if (s[i][j]='.') then
				begin
					delete(s[i],j,1);
					insert('!',s[i],j);
				end;
	end;
	for i:=1 to 9 do
	begin
		insert(' ',s[i],4);
		insert(' ',s[i],8);
	end;
	for i:=1 to 9 do
	begin
		writeln(s[i]);
		if i mod 3 = 0 then writeln;
	end;
end.

var a: array [1..11,1..11] of char;
    x,y,i,j,n,m,k: byte;
begin
 n:=0; m:=0; k:=0;
 for i:=1 to 11 do begin
  if i mod 4>0 then
  for j:=1 to 11 do
   read(a[i,j]);
  readln;
  end;
 read(x,y);
 if (x=1)or(x=4)or(x=7) then n:=1; if (x=3)or(x=6)or(x=9) then n:=9; if n=0 then n:=5;
 if (y=1)or(y=4)or(y=7) then m:=1; if (y=3)or(y=6)or(y=9) then m:=9; if m=0 then m:=5;
 for i:=n to n+2 do
  for j:=m to m+2 do
   if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;
 if k=0 then
  for i:=1 to 11 do
   for j:=1 to 11 do
    if a[i,j]='.' then a[i,j]:='!';
 for i:=1 to 11 do begin
  if i mod 4>0 then
  for j:=1 to 11 do
   write(a[i,j]);
   writeln;
   end;
 end.

var
s:array[-10..1000]of string;
bol:boolean;
i,j,x,y,l,r,ll,rr:longint;
begin
for i:=1  to 11 do begin
    readln(s[i]);
end;
readln(x,y);
x:=x mod 3;
y:=y mod 3;
if y=0 then y:=3;
if x=0 then x:=3;
if x=1 then begin
    l:=1;
    r:=3;
end;
if x=2 then begin
    l:=5;
    r:=7;
end;
if x=3 then begin
    l:=9;
    r:=11;
end;
if y=1 then begin
    ll:=1;
    rr:=3;
end;
if y=2 then begin
    ll:=5;
    rr:=7;
end;
if y=3 then begin
    ll:=9;
    rr:=11;
end;

for i:=l to r do begin
    for j:=ll to rr do begin
        if s[i][j]='.' then begin
            s[i][j]:='!';
            bol:=true;
        end;
    end;
end;

if bol =false then begin
    for i:=1 to 11 do
    for j:=1 to length(s[i]) do begin
        if s[i][j]='.' then s[i][j]:='!';
    end;
end;
for i:=1 to 11 do begin
write(s[i]);
writeln;
end;
end.

var s:array[1..100] of string;
    i,k,n,x,y,kol,j:longint;
begin
i:=1;
while i<=9 do
begin
 readln(s[i]);
 k:=pos(' ',s[i]);
 delete(s[i],k,1);
 k:=pos(' ',s[i]);
 delete(s[i],k,1);
 if s[i]<>''
 then inc(i);
end;
readln(x,y);
x:=x mod 3;
y:=y mod 3;
if x=0
then x:=3;
if y=0
then y:=3;
x:=(x*3)-2;
y:=(y*3)-2;
 kol:=0;
 for i:=x to x+2 do
  for j:=y to y+2 do
  if s[i,j]='.'
  then inc(kol);
 if kol=0
 then for i:=1 to 9 do
       for j:=1 to 9 do
        if s[i,j]='.'
        then s[i,j]:='!';
 if kol>0
 then for i:=x to x+2 do
       for j:=y to y+2 do
       if s[i,j]='.'
       then s[i,j]:='!';

for i:=1 to 9 do
begin
 for j:=1 to 9 do
  if j mod 3=0
  then write(s[i,j],' ')
  else write(s[i,j]);
  writeln;

 if i mod 3=0
 then writeln;
end;
end.

var
 a:array[1..9,1..9] of integer;
 s:string;
  j,i,x,y,k:integer;

  procedure sx();
  begin
  if copy(s,1,1)='.' then a[i,j]:=0;
  if copy(s,1,1)='x' then a[i,j]:=1;
  if copy(s,1,1)='o' then a[i,j]:=2;
  delete(s,1,1);
  end;

  procedure qx();
  begin
  if a[i,j]=0 then  write('.');
  if a[i,j]=1 then  write('x');
  if a[i,j]=2 then  write('o');
  if a[i,j]=4 then  write('!');
  end;

 Begin
  for i:=1 to 3 do begin
   readln(s);
   for j:=1 to 3 do
    sx;
   delete(s,1,1);
   for j:=4 to 6 do
    sx;
   delete(s,1,1);
   for j:=7 to 9 do
    sx;
   delete(s,1,1); end;
   readln;
   for i:=4 to 6 do begin
   readln(s);
   for j:=1 to 3 do
    sx;
   delete(s,1,1);
   for j:=4 to 6 do
    sx;
   delete(s,1,1);
   for j:=7 to 9 do
    sx;
   delete(s,1,1); end;
   readln;
   for i:=7 to 9 do begin
   readln(s);
   for j:=1 to 3 do
    sx;
   delete(s,1,1);
   for j:=4 to 6 do
    sx;
   delete(s,1,1);
   for j:=7 to 9 do
    sx;
   delete(s,1,1); end;

   readln(x,y);

   if(x=1)or(x=4)or(x=7) then x:=1;
   if(x=2)or(x=5)or(x=8) then x:=2;
   if(x=3)or(x=6)or(x=9) then x:=3;
   if(y=1)or(y=4)or(y=7) then y:=1;
   if(y=2)or(y=5)or(y=8) then y:=2;
   if(y=3)or(y=6)or(y=9) then y:=3;

   k:=0;

   for i:=x*3-2 to x*3 do
    for j:=y*3-2 to y*3 do
     if a[i,j]=0 then begin
      k:=1;
      a[i,j]:=4; end;

      if k=0 then
       for i:=1 to 9 do
    for j:=1 to 9 do
     if a[i,j]=0 then
      a[i,j]:=4;

      if k=1 then
      for i:=x*3-2 to x*3 do
    for j:=y*3-2 to y*3 do
     if a[i,j]=0 then
      a[i,j]:=4;

      for i:=1 to 3 do begin
       for j:=1 to 3 do
        qx;
       write(' ');
       for j:=4 to 6 do
        qx;
       write(' ');
       for j:=7 to 9 do
        qx;
       writeln;
       end;

       writeln;

        for i:=4 to 6 do begin
       for j:=1 to 3 do
        qx;
       write(' ');
       for j:=4 to 6 do
        qx;
       write(' ');
       for j:=7 to 9 do
        qx;
       writeln;
       end;

       writeln;

       for i:=7 to 9 do begin
       for j:=1 to 3 do
        qx;
       write(' ');
       for j:=4 to 6 do
        qx;
       write(' ');
       for j:=7 to 9 do
        qx;
       writeln;
       end;

 End.

var
str:array[1..11] of string;
x,y,ans,i,j:integer;

begin

for i:=1 to 11 do
readln(str[i]);

readln(x,y);

x:=x mod 3;
if x = 0 then x:=3;

y:=y mod 3;
if y = 0 then y:=3;

ans:=0;

for i:=4*x - 3 to 4*x - 1 do
for j:=4*y - 3 to 4*y - 1 do
if str[i][j] = '.' then
begin
str[i][j] := '!';
ans:=1;
end;

if ans = 0 then
for i:=1 to 11 do
for j:=1 to 11 do
if i mod 4 > 0 then
if str[i][j] = '.' then
str[i][j] := '!';

for i:=1 to 11 do
writeln(str[i]);

end.

var c:array[1..3,1..3,1..3,1..3] of boolean;
q:array[1..3,1..3,1..3,1..3] of char;
i,j,k,l,m,n,x,y,a,b,w,d:longint;
p:char;
s:string;

function check(x,y:longint):boolean;
var i,j:longint;
begin
for i:=1 to 3 do
for j:=1 to 3 do
if not c[x,y,i,j] then check:=true
end;

procedure doit(x,y:longint);
var i,j:longint;
begin
for i:=1 to 3 do
for j:=1 to 3 do
if q[x,y,i,j]='.' then q[x,y,i,j]:='!'
end;

begin
for i:=1 to 11 do
begin
if i mod 4<>0 then
n+=1 else
begin
readln(s);
continue
end;
m:=0;
for j:=1 to 11 do
begin
read(p);
if p<>' ' then m+=1;
if n mod 3=0 then x:=3 else x:=n mod 3;
if m mod 3=0 then y:=3 else y:=m mod 3;
if (p<>' ') and (p<>'.') and (p<>'') then
begin
c[(n+2) div 3,(m+2) div 3,x,y]:=true;

end;
if p<>' ' then
q[(n+2) div 3,(m+2) div 3,x,y]:=p;
end;

readln;
end;

read(x,y);

a:=(x+2) div 3;
b:=(y+2) div 3;
if x mod 3=0 then w:=3 else w:=x mod 3;
if y mod 3=0 then d:=3 else d:=y mod 3;

if check(w,d) then doit(w,d) else
begin
for i:=1 to 3 do
for j:=1 to 3 do
doit(i,j)
end;

for k:=1 to 3 do
begin
for l:=1 to 3 do
begin
for j:=1 to 3 do
begin
for i:=1 to 3 do
write(q[k,j,l,i]);write(' ');
end;
writeln;
end;
writeln
end;
end.

program qq;
var a: array [1..9,1..9] of char;
c: char;
x,y,j,m,p:integer;
begin
j:=1;
while j<=9 do begin
 m:=1;
while m<=9 do begin
read (c);
if (c='.') or (c='x') or (c='o') then begin a[j,m]:=c; m:=m+1; end;
end;
j:=j+1 end;
read (x,y);
j:= 3*(x mod 3)-2; m:= 3*(y mod 3) - 2;
if j=-2 then j:=7; if m=-2 then m:=7; p:=0;
for i:integer:=j to j+2 do
for n:integer:=m to m+2 do
if a[i,n]='.' then begin p:=1; a[i,n]:='!'; end;
if p=0 then
for i:integer:=1 to 9 do
for n:integer:=1 to 9 do if a[i,n]='.' then a[i,n]:='!';
for i:integer:=1 to 9 do begin

if i=4 then writeln (); if i=7 then writeln ();
for n:integer:=1 to 9 do begin
if n=4 then write (' '); if n=7 then write (' ');
write (a[i,n]);
end;if i<>9 then writeln ();
end;
end.

program bbb;
var s: string;
    a: array [1..9,1..9] of integer;
    i,j,c,l,x: integer;
begin

  c:=0;
  for i:=1 to 11 do
    begin
      readln(s);
      if (i<>4) and (i<>8) then
      begin
        inc(c);
        l:=0;
        for j:=1 to length(s) do begin
          if s[j]<>' ' then
            begin
              inc(l);
              if s[j]='.' then a[c,l]:=0;
              if s[j]='x' then a[c,l]:=1;
              if s[j]='o' then a[c,l]:=2;
            end;
        end;
      end;
      //writeln(i);
    end;
  read(c,l);
  c:=c mod 3;
  if c=0 then c:=3;
  l:=l mod 3;
  if l=0 then l:=3;
  x:=0;
  for i:=c*3-2 to c*3 do
    for j:=l*3-2 to l*3 do if a[i,j]=0 then
      begin
        a[i,j]:=3;
        inc(x);
      end;
  c:=0;
  l:=0;
  for i:=1 to 11 do
  begin
    if (i<>4) and (i<>8) then
      begin inc(c);
      l:=0;
      for j:=1 to 11 do
        begin
          if (j<>4) and (j<>8) then begin
          inc(l);
         // writeln(c,l);
          if a[c,l]=1 then write('x');
          if a[c,l]=2 then write('o');
          if a[c,l]=3 then write('!');
          if (x>0) and (a[c,l]=0) then write('.');
          if (x=0) and (a[c,l]=0) then write('!');
          end
          else write(' ');
        end;
      end;
    writeln;
  end;
end.

var
ch:char;
bol: boolean;
a,b,i,secx,secy,secn,absa,absb: integer;
arr: array[1..9] of array[1..9] of integer;
t: text;
begin

a:=1;
b:=1;
while i<119 do
begin
i:=i+1;
read(ch);
if (ch='x') then
begin
arr[a][b]:=1;
b:=b+1;
if b=10 then begin b:=1; a:=a+1; end;
end
else if ch=('o') then
begin
arr[a][b]:=2;
b:=b+1;
if b=10 then begin b:=1; a:=a+1; end;
end
else
if ch='.' then
begin
b:=b+1;
if b=10 then begin b:=1; a:=a+1; end;
end;
end;
readln(b,a);
absa:=a;
absb:=b;
while absa>3 do absa:=absa-3;
while absb>3 do absb:=absb-3;
for a:=(absa-1)*3+1 to absa*3 do
for b:=(absb-1)*3+1 to absb*3 do
begin
if arr[b][a]=0 then begin bol:=true; arr[b][a]:=3; end;
end;
if bol = false then
begin
for a:=1 to 9 do
for b:=1 to 9 do
if arr[a][b]=0 then arr[a][b]:=3;
end;
for a:=1 to 9 do
begin
for b:=1 to 9 do
begin
if arr[a][b] = 0 then write('.');
if arr[a][b] = 1 then write('x');
if arr[a][b] = 2 then write('o');
if arr[a][b] = 3 then write('!');
if b<>1 then if b mod 3 = 0 then write(' ');
end;
writeln();
if a<>1 then if a mod 3 = 0 then
writeln();
end;
end.

var
  a: array [1..3] of array [1..3] of array [1..3] of array [1..3] of byte;
  x, y, k: byte;
  s: string;

begin
  for var i1 := 1 to 9 do
  begin
    readln(s);
    if s = '' then
      readln(s);
    delete(s, pos(' ', s), 1);
    delete(s, pos(' ', s), 1);
    for var i2 := 1 to 9 do
      case s[i2] of
        'x': a[(i1 - 1) div 3 + 1][(i2 - 1) div 3 + 1][(i1 - 1) mod 3 + 1][(i2 - 1) mod 3 + 1] := 1;
        'o': a[(i1 - 1) div 3 + 1][(i2 - 1) div 3 + 1][(i1 - 1) mod 3 + 1][(i2 - 1) mod 3 + 1] := 2;
      end;
  end;
  readln(y, x);
  for var i3 := 1 to 3 do
    for var i4 := 1 to 3 do
      if a[(y - 1) mod 3 + 1][(x - 1) mod 3 + 1][i3][i4] = 0 then
      begin
        a[(y - 1) mod 3 + 1][(x - 1) mod 3 + 1][i3][i4] := 3;
        k += 1;
      end;
  if k = 0 then
    for var i5 := 1 to 3 do
      for var i6 := 1 to 3 do
        for var i7 := 1 to 3 do
          for var i8 := 1 to 3 do
            if a[i5][i6][i7][i8] = 0 then
              a[i5][i6][i7][i8] := 3;
  for var i9 := 1 to 9 do
  begin
    for var i10 := 1 to 9 do
    begin
      case a[(i9 - 1) div 3 + 1][(i10 - 1) div 3 + 1][(i9 - 1) mod 3 + 1][(i10 - 1) mod 3 + 1] of
        0: write('.');
        1: write('x');
        2: write('o');
        3: write('!');
      end;
      case i10 of
        3, 6: write(' ');
      end;
    end;
    writeln;
    case i9 of
      3, 6, 9: writeln;
    end;

  end;
end.

var a:array[1..9,1..9]of string;
    x,y,k,i,j:integer;
    c:char;
begin
for j:=1 to 9 do
     for i:=1 to 9 do begin
          read(c);
          while not((c='.')or(c='x')or(c='o'))do read(c);
          a[i,j]:=c;
     end;

read(y,x);
x:=(x-1)mod 3;
y:=(y-1)mod 3;

k:=0;
for j:=y*3+1 to (y+1)*3 do
     for i:=x*3+1 to (x+1)*3 do
          if a[i,j]='.' then inc(k);

if k>0 then begin
     for j:=y*3+1 to (y+1)*3 do
          for i:=x*3+1 to (x+1)*3 do
               if a[i,j]='.' then a[i,j]:='!'
      end else
     for j:=1 to 9 do
          for i:=1 to 9 do
               if a[i,j]='.' then a[i,j]:='!';

for j:= 1 to 3 do begin
     for i:=1 to 3 do write(a[i,j]);
     write(' ');
     for i:=4 to 6 do write(a[i,j]);
     write(' ');
     for i:=7 to 9 do write(a[i,j]);
     writeln(' ');
end;
writeln(' ');
for j:= 4 to 6 do begin
     for i:=1 to 3 do write(a[i,j]);
     write(' ');
     for i:=4 to 6 do write(a[i,j]);
     write(' ');
     for i:=7 to 9 do write(a[i,j]);
     writeln(' ');
end;
writeln(' ');
for j:= 7 to 9 do begin
     for i:=1 to 3 do write(a[i,j]);
     write(' ');
     for i:=4 to 6 do write(a[i,j]);
     write(' ');
     for i:=7 to 9 do write(a[i,j]);
     writeln(' ');
end;
end.

var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;
  begin
  for i:=1 to 9 do
    begin
     readln(s);
     for l:=1 to 11 do
      begin
       if (l=4) or (l=8) then continue;
       if (l>4) and (l<8) then u:=l-1;
       if (l>8) then u:=l-2;
       if (l<4) then u:=l;
       a[i, u]:=s[l];
      end;
    if (i<9) and (i mod 3 = 0 ) then readln(s);
    end;
   read(x,y);
   if a[x,y]='o' then chir:='x' else chir:='o';
   flag:=true;
   if x mod 3 = 0 then
   line:=3;
   if x mod 3 = 2 then
    line:=2;
   if x mod 3 = 1 then
   line:=1;
   if y mod 3 = 0 then
   col:=3;
   if y mod 3 = 2 then
   col:=2;
   if y mod 3 = 1 then
   col:=1;
   for i:=line*3-2 to line*3 do
   for j:=col*3-2 to col*3 do
   if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;
   if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';
 for i:=1 to 9 do
    begin
    for j:=1 to 3 do
      begin
        for l:=j*3-2 to j*3 do write(a[i, l]);
        write(' ');
      end;
    writeln;
    if (i<9) and (i mod 3 = 0 ) then writeln;
    end;

 end.

var
  a: array[1..9, 1..9] of char;
  bufer: char;

var
  i, j, iwant, jwant, found: longint;

procedure full;
var
  i, j: longint;
begin

  if found = 0 then
  begin
    for i := 1 to 9 do
      for j := 1 to 9 do
      begin
        if a[i, j] = '.' then a[i, j] := '!';
      end;
  end;

end;

procedure normal;
var
  i, j: longint;
begin
  for i := 1 to 9 do
    for j := 1 to 9 do
    begin
      if (i > ((iwant - 1) * 3) ) and (i <= (iwant * 3) ) then
        if (j > ((jwant - 1) * 3) ) and (j <= (jwant * 3) ) then
          if a[i, j] = '.' then
          begin
            found := 1;
            a[i, j] := '!';
          end;
    end;
end;

procedure outwrite;
var
  i, j: longint;
begin
  for i := 1 to 9 do
  begin
    for j := 1 to 9 do
    begin
      write(a[i, j]);
      if (j = 3) or (j = 6) then write(' ');
    end;
    writeln;
    if (i = 3) or (i = 6) then writeln;
  end;
end;

begin
  i := 1;
  while true do
  begin
    j := 1;
    while true do
    begin
      read(bufer);
      if (bufer = '.') or (bufer = 'o') or (bufer = 'x') then begin a[i, j] := bufer;inc(j); end;
      if j = 10 then break;
    end;
    inc(i);
    if i = 10 then break;
  end;
  readln(iwant, jwant);
  while iwant > 3 do
  begin
    iwant := iwant - 3;
  end;
  while jwant > 3 do
  begin
    jwant := jwant - 3;
  end;
  found := 0;
  normal;
  full;
  outwrite;
end.

Program CodeF_454_B;
var x,y,i,j,i1,j1,n:longint;
    m:array[1..1]of longint;
    //reb:array[1..1]of array[1..2]of longint;
    p:array[0..8]of array[0..8]of longint;
    s:string;
    mogu:boolean;

begin
i1:=-1;
for i:=1 to 11 do
  begin
  readln(s);
  if length(s)=11 then
    begin
    inc(i1);
    j1:=-1;
    for j:=1 to 11 do
      begin
      if s[j]<>' ' then inc(j1);
      if s[j]='o' then
        begin
        p[i1][j1]:=1;
        end;
      if s[j]='x' then
        begin
        p[i1][j1]:=2;
        end;
      end;
    end;
  end;
read(x, y);
x:=(x-1) mod 3;
y:=(y-1) mod 3;
mogu:=false;
for i:=0 to 8 do
  for j:=0 to 8 do
    if (i div 3=x) and (j div 3=y) then
    begin
    if p[i][j]=0 then
      mogu:=true;
    end;

if mogu=true then
  for i:=0 to 8 do
    for j:=0 to 8 do
      begin
      if p[i][j]=0 then
         if (i div 3=x) and (j div 3=y) then
        p[i][j]:=3;
      end else
  begin
  for i:=0 to 8 do
    for j:=0 to 8 do
      if p[i][j]=0 then
        p[i][j]:=3;
  end;

for i:=0 to 8 do
  begin
  if (i mod 3=0) and (i<>0) then
    writeln;
  for j:=0 to 8 do
    begin
    if (j mod 3=0) and (j<>0) then
      write(' ');
    if p[i][j]=0 then write('.');
    if p[i][j]=1 then write('o');
    if p[i][j]=2 then write('x');
    if p[i][j]=3 then write('!');
    end;
    writeln;
  end;

end.

program Program1;
var i,j,x,y: integer;
  test: boolean;
  S: array[1..9] of string;
begin
  for i:=1 to 9 do begin
    if (i=4)or(i=7) then
      readln();
    readln(s[i]);
  end;
  read(x,y);
  test:=false;
  if ((x=1)or(x=4)or(x=7))and((y=1)or(y=4)or(y=7)) then begin
    for i:=1 to 3 do begin
      for j:=1 to 3 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=1)or(x=4)or(x=7))and((y=2)or(y=5)or(y=8)) then begin
    for i:=1 to 3 do begin
      for j:=5 to 7 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=1)or(x=4)or(x=7))and((y=3)or(y=6)or(y=9)) then begin
    for i:=1 to 3 do begin
      for j:=9 to 11 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=2)or(x=5)or(x=8))and((y=1)or(y=4)or(y=7)) then begin
    for i:=4 to 6 do begin
      for j:=1 to 3 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=2)or(x=5)or(x=8))and((y=2)or(y=5)or(y=8)) then begin
    for i:=4 to 6 do begin
      for j:=5 to 7 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=2)or(x=5)or(x=8))and((y=3)or(y=6)or(y=9)) then begin
    for i:=4 to 6 do begin
      for j:=9 to 11 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=3)or(x=6)or(x=9))and((y=1)or(y=4)or(y=7)) then begin
    for i:=7 to 9 do begin
      for j:=1 to 3 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=3)or(x=6)or(x=9))and((y=2)or(y=5)or(y=8)) then begin
    for i:=7 to 9 do begin
      for j:=5 to 7 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  if ((x=3)or(x=6)or(x=9))and((y=3)or(y=6)or(y=9)) then begin
    for i:=7 to 9 do begin
      for j:=9 to 11 do begin
        if S[i][j]='.' then begin
          S[i][j]:='!';
          test:=true;
        end;
      end;
    end;
    if test=false then begin
      for i:=1 to 9 do begin
        for j:=1 to 11 do begin
          if S[i][j]='.' then begin
            S[i][j]:='!';
          end;
        end;
      end;
    end;
  end;
  for i:=1 to 9 do begin
    if (i=4)or(i=7) then
      writeln();
    writeln(S[i]);
  end;
end.

var
  big: array[1..9, 1..9] of integer;
  strs: array[1..9] of string;
  k, num, x, y, i, j, x1, x2, y1, y2: integer;
  ch: char;
  s: string;

begin

  for i := 1 to 9 do
  begin

    k := -1; j := 1;
    while (j <= 9) do
    begin
      read(ch);
      if (ch = 'x')  then k := 1;
      if(ch = 'o') then k := 2;
      if(ch = '.') then k := 0;
      if(k >= 0) then
      begin
        big[i, j] := k;
        inc(j);
      end;
      k := -1;
    end;

  end;
  read(y, x);

  x := x mod 3;
  y := y mod 3;
  if(x = 1) then
  begin
    x1 := 1;
    x2 := 3;
  end else
  if(x = 2) then
  begin
    x1 := 4;
    x2 := 6;
  end else
  begin
    x1 := 7;
    x2 := 9;
  end;
  if(y = 1) then
  begin
    y1 := 1;
    y2 := 3;
  end else
  if(y = 2) then
  begin
    y1 := 4;
    y2 := 6;
  end else
  begin
    y1 := 7;
    y2 := 9;
  end;
  num := 0;
  for i := y1 to y2 do
    for j := x1 to x2 do
    begin
      if(big[i, j] = 0) then
        inc(num);
    end;

  if(num = 0) then begin
    x1 := 1;
    x2 := 9;
    y1 := 1;
    y2 := 9;
  end;
  for i := 1 to 9 do
  begin
    s := '';
    for j := 1 to 9 do
    begin
      if(big[i, j] = 1) then
        s += 'x';
      if(big[i, j] = 2) then s += 'o';
      if(big[i, j] = 0) then
      begin
        if(i <= y2 ) and (i >= y1) and (j <= x2) and (j >= x1) then
          s += '!' else s += '.';
      end;
      if(j mod 3 = 0) then s += ' ';

    end;
    writeln(s);
    if(i mod 3 = 0) then writeln;
  end;

end.

var
  a:array[1..9,1..9] of char;
  rep:char;
  var i,j:longint; //������ �������
  ineed,jneed,found:longint;
begin
  i:=1;
  while true do begin
  j:=1;
   while true do
    begin
     read(rep);
     if (rep = '.') or (rep = 'o') or (rep = 'x') then begin a[i,j]:=rep; inc(j); end;
     if j = 10 then break;
    end;
    inc(i);
    if i = 10 then break;
   end;
  readln(ineed,jneed);
  while ineed > 3 do
   begin
    ineed:=ineed - 3;
   end;
  while jneed > 3 do
   begin
    jneed:=jneed - 3;
   end;
  found:=0;
  for i:=1 to 9 do
   for j:=1 to 9 do
    begin
     if (i>((ineed-1)*3) ) and (i <= (ineed*3) ) then
      if (j>((jneed-1)*3) ) and (j <= (jneed*3) ) then
       if a[i,j] = '.' then
        begin
         found := 1;
         a[i,j]:='!';
        end;
    end;
  if found = 0 then
   begin
    for i:=1 to 9 do
     for j:=1 to 9 do
      begin
       if a[i,j]='.' then a[i,j]:='!';
      end;
   end;
  for i:=1 to 9 do
   begin
   for j:=1 to 9 do
    begin
     write(a[i,j]);
     if (j = 3) or (j = 6) then write(' ');
    end;
   writeln;
   if (i = 3) or (i = 6) then writeln;
   end;
end.

Var
	a: array [1..11,1..11] of integer;
    x, y, i, j, k, n, m, l, s:integer;
	ch,pr : char;
	f:boolean;
begin
   x := 0;
   y := 0;
	for i := 1 to 9 do
    begin
        if (i = 4) or (i = 7) then readln;
        inc(x);
        y := 0;
		for j := 1 to 9 do
		begin
			if (j = 4) or (j = 7) then read(pr);
			read(ch);
            inc(y);
			case ch of
			'.': a[x,y] := 0;
			'o': a[x,y] := 1;
			'x': a[x,y] := 2;
			end;
           // writeln(ch, ' ', x, ' ', y);

		end;

        readln;
        end;

        {for i := 1 to 9 do
            begin
            for j := 1 to 9  do
            write(a[i,j],' ');

            writeln;
            end;}
		read(x,y);
		//writeln(x,' ',y);
		while (x-3 > 0) do x := x-3;
		while (y-3 > 0) do y := y-3;
		//writeln(x,' ',y);
		x := (x-1)*3+1;
		y := (y-1)*3+1;
        //writeln(x,' ',y);
		f := false;
		for i := x to x+2 do
			for j := y to y+2 do
				if (a[i,j] = 0) then begin
				a[i,j] := 3;
				f := true;
				end;

		for i  := 1 to 9 do
			begin
			for j := 1 to 9 do
			begin
				case a[i,j] of
				0: if (f <> false) then
				write('.')
				else
				write('!');
				1: write('o');
				2: write('x');
				3: write('!');
				end;
			if (j = 3) or (j = 6)  then write(' ');
			if (j = 9) then writeln;
			end;
			if (i = 3) or (i = 6) then writeln;

			end;
	{	case x of
		1: case y of
			1: n = 1;
			2: n = 2;
			3: n = }
end.

var
  a: array [1..11, 1..11] of char;
  i, j, n, m, k: integer;
  isNotFull: boolean;

begin
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      readln();
      continue;
    end;
    for j := 1 to 11 do read(a[i, j]);
    readln();
  end;
  read(n, m);
  isNotFull := false;
  if (n >= 4) and (n <= 6) then n += 1
  else if (n >= 7) and (n <= 9) then n += 2;
  if (m >= 4) and (m <= 6) then m += 1
  else if (m >= 7) and (m <= 9) then m += 2;
  if (n = 1) or (n = 5) or (n = 9) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 1 to 3 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 1 to 3 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 1 to 3 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 2) or (n = 6) or (n = 10) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 5 to 7 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 5 to 7 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 5 to 7 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 3) or (n = 7) or (n = 11) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 9 to 11 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 9 to 11 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 9 to 11 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if isNotFull = false then for i := 1 to 11 do
      for j := 1 to 11 do
        if a[i, j] = '.' then a[i, j] := '!';
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      writeln();
      continue;
    end;
    for j := 1 to 11 do write(a[i, j]);
    writeln();
  end;
end.

program cupB;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var a:array[1..9,1..9] of char;
    i,j,k,x,y:integer;
    flagg:boolean;
    sim:char;
begin
  { TODO -oUser -cConsole Main : Insert code here }
  for i:=1 to 9 do
  begin
   for j:=1 to 9 do
   begin
    read(a[i,j]);
    if (j=3) or (j=6) then read(sim);
   end;
   readln;
    if (i=3) or (i=6) then readln;
  end;
  readln(x,y);
  x:=x mod 3;
  if x=0 then x:=3;
  y:=y mod 3;
  if y=0 then y:=3;

  flagg:=false;
  for i:=(x-1)*3+1 to 3*x do
  for j:=(y-1)*3+1 to 3*y do
  if a[i,j]='.' then
  begin
     flagg:=true;
     a[i,j]:='!';
  end;
  if flagg=false then
  begin
     for i:=1 to 9 do
     for j:=1 to 9 do
     if a[i,j]='.' then a[i,j]:='!';
  end;

  for i:=1 to 9 do
  begin
    for j:=1 to 9 do
    begin
       write(a[i,j]);
       if (j=3) or (j=6) then write(' ');
    end;
    writeln;
    if (i=3) or (i=6) then writeln;
  end;
end.

var
  Field: array [1..9, 1..9] of Char;
  s, str: string;
  i, j, x, y: LongInt;
  Filled: Boolean;

procedure SuperTrim(var s: string);
var
  minus: LongInt;
begin
  minus := 0;
  For i := 1 to Length(s) do
  begin
    If ord(s[i-minus]) < 33 then
    begin
      Delete(s, i-minus, 1);
      inc(minus);
    end;
  end;
end;

begin
  ReadLn(s);
  For i := 2 to 11 do
  begin
    ReadLn(str);
    s := s + str;
  end;

  SuperTrim(s);

  For i := 1 to 9 do
  begin
    For j := 1 to 9 do
    begin
      Field[i, j] := s[(i-1)*9 + j];
    end;
  end;

  Read(y, x);
  ReadLn;
  x := ((x - 1) mod 3)*3 + 1;
  y := ((y - 1) mod 3)*3 + 1;

  Filled:=True;
  For i := 0 to 2 do
  begin
    For j := 0 to 2 do
    begin
      If Field[y+i, x+j] = '.' then Filled := False;
    end;
  end;

  If Filled then
  begin
    For i := 1 to 9 do
    begin
      For j := 1 to 9 do
      begin
        If Field[i, j] = '.' then Field[i, j] := '!'
      end;
    end;
  end else
  begin
    For i := 0 to 2 do
    begin
      For j := 0 to 2 do
      begin
        If Field[y+i, x+j] = '.' then Field[y+i, x+j] := '!'
      end;
    end;
  end;

  For i := 1 to 9 do
  begin
    For j := 1 to 9 do
    begin
      Write(Field[i, j]);
      If (j = 3) or (j = 6) then Write(' ');
    end;
    If (i = 3) or (i = 6) then WriteLn('');
    WriteLn('');
  end;
end.

var s:array[0..12] of string;
var x,y,i,j:longint;
var r:boolean;
begin
  for i:=1 to 9 do begin if (i=4) or (i=7) then readln(s[i]);readln(s[i]);
  delete(s[i],4,1);delete(s[i],7,1);end;
  readln(x,y);x:=x mod 3;y:=y mod 3;r:=false;
  if x=0 then x:=3;if y=0 then y:=3;
  for i:=x*3-2 to x*3 do
    for j:=y*3-2 to y*3 do if s[i,j]='.' then begin r:=true;s[i,j]:='!';end;
  if not r then for i:=1 to 9 do for j:=1 to 9 do if s[i,j]='.' then
  s[i,j]:='!';
  for i:=1 to 9 do
  begin
    for j:=1 to 9 do
    begin
      if (j=4) or (j=7) then write(' ');
      write(s[i,j]);
    end;
    writeln;
    if (i=3) or (i=6) then writeln;
  end;
  writeln;
end.

var a:array[0..1000]of string;
x,y,i,j:longint;f:boolean;
begin
//assign(input,'tictactoe.in');reset(input);
//assign(output,'tictactoe.out');rewrite(output);
for I:=1 to 9 do
  begin
  if(i=4)or(i=7)then readln(a[i]);
  readln(a[i]);
  delete(a[i],8,1);
  delete(a[i],4,1);
  end;
read(x,y);
x:=(x-1)mod 3+1;
y:=(y-1)mod 3+1;
f:=false;
for i:=(x-1)*3+1 to x*3 do
  for j:=(y-1)*3+1 to y*3 do
    if a[i,j]='.' then
      f:=true;
if not f then
  begin
  for i:=1 to 9 do
    for j:=1 to 9 do
      if a[i,j]='.' then a[i,j]:='!';
  end
else
  for i:=(x-1)*3+1 to x*3 do
    for j:=(y-1)*3+1 to y*3 do
      if a[i,j]='.' then
        a[i,j]:='!';
for i:=1 to 9 do
  begin
  for j:=1 to 9 do
    begin
    write(a[i,j]);
    if(j=3)or(j=6)then write(' ');
    end;
  writeln;
  if(i=3)or(i=6)then writeln;
  end;
close(input);close(output);
end.

var
  a : array[ 1..9, 1..9 ] of char;
  temp : char;
  i, j, nemp, x, y, kx, ky : longint;
begin
  for i := 1 to 9 do
    begin
      for j := 1 to 9 do
        begin
          read( a[ i, j ] );
          if j mod 3 = 0
            then read( temp );
        end;
      readln;
      if ( i mod 3 = 0 )  and ( i <> 9 )
        then readln;
    end;
  readln( x, y );
  while x > 3 do
    x := x - 3;
  while y > 3 do
    y := y - 3;
  kx := x - 1;
  ky := y - 1;
  for i := kx * 3 + 1 to kx * 3 + 3 do
    for j := ky * 3 + 1 to ky * 3 + 3 do
      if a[ i, j ] <> '.'
        then inc( nemp )
        else a[ i, j ] := '!';
  if nemp = 9
    then
      begin

        for i := 1 to 9 do
          begin
            for j := 1 to 9 do
              begin
                if a[ i, j ] <> '.'
                  then write( a[ i, j ] )
                  else write( '!' );
                if j mod 3 = 0
                  then write( ' ' );
              end;
            writeln;
            if i mod 3 = 0
              then writeln;
          end;
      end
    else
      begin

        for i := 1 to 9 do
          begin
            for j := 1 to 9 do
              begin
                write( a[ i, j ] );
                if j mod 3 = 0
                  then write( ' ' );
              end;
            writeln;
            if i mod 3 = 0
              then writeln;
          end;
      end;
end.

program Crosses_Ouths_B_907;

// {$H+} // FPC - long strings
// {$M 8000000} // FPC - stack size is 8MB
// {$M 8000000, 16000, 640000} // TP - stack size is 8MB

// {$DEFINE ONLINE_JUDGE}
procedure DivByZero;
var
  I, J: Integer;
begin
  I := 0;
  J := 10 div I;
end;

const
  MaxN = 3;
  MaxM = 3;
type
  TField = array [1..MaxN, 1..MaxN] of Char;
  TBigField = array [1..MaxM, 1..MaxM] of TField;
var
  BigF: TBigField;
  S: string;
  N, I, J, K, P, fI, fJ, L: Longint;
  X, Y, fX, fY: Longint;
  Check: Boolean;
begin
  {$IFNDEF ONLINE_JUDGE}
  Assign(Input,'Nin.txt');
  Assign(Output,'Nout.txt');
  Reset(Input);
  Rewrite(Output);
  {$ENDIF}
  FillChar(BigF, Sizeof(BigF), '.');
  for K := 1 to MaxM * MaxM do
  begin
    Readln(S);
    while length(S) = 0 do
      Readln(S);
    fI := (K - 1) div MaxM + 1;
    while pos(' ', S) <> 0 do
      delete(S, pos(' ', S), 1);
    L := Length(S);
    if L <> MaxN * MaxM then
      DivByZero;
    I := (K - 1) mod MaxN + 1;
    for P := 1 to L do
    begin
      fJ := (P - 1) div MaxM + 1;
      J := (P - 1) mod MaxN + 1;
      BigF[fI, fJ][I, J] := S[P];
    end;
  end;

  Read(X, Y);
  fX := (X - 1) mod MaxM + 1;
  fY := (Y - 1) mod MaxM + 1;
  Check := False;
  for I := 1 to MaxN do
    for J := 1 to MaxN do
      if BigF[fX, fY][I, J] = '.' then
        Check := True;
  if Check then
  begin
    for I := 1 to MaxN do
      for J := 1 to MaxN do
        if BigF[fX, fY][I, J] = '.' then
          BigF[fX, fY][I, J] := '!'
  end
  else
  begin
    for fI := 1 to MaxM do
      for fJ := 1 to MaxM do
        for I := 1 to MaxN do
          for J := 1 to MaxN do
            if BigF[fI, fJ][I, J] = '.' then
              BigF[fI, fJ][I, J] := '!';
  end;
  for fI := 1 to MaxM do
  begin
    for I := 1 to MaxN do
    begin
      for fJ := 1 to MaxM do
      begin
        for J := 1 to MaxN do
          Write(BigF[fI, fJ][I, J]);
        if fJ <> MaxN then
          Write(' ');
      end;
      Writeln;
    end;
    if fI <> MaxM then
      Writeln;
  end;

  {$IFNDEF ONLINE_JUDGE}
  Close(Input);
  Close(Output);
  {$ENDIF}
end.

//{$R-,Q-,S-,I-}
Uses math;
Const
        fin='';
        fon='';
	//fin='.inp';
	//fon='.out';
        maxC=1000000000;
        maxN=1000+10;
	module=1000000007;
        mang:array[1..9] of longint=(1,2,3,1,2,3,1,2,3);

Type
	pnode=^tnode;
        tnode=record
                v,c:longint;
                next:pnode;
		end;
	re=record
		x,y:longint;
		end;

Var
        fi,fo:text;
	n,x,y:longint;
        a:array[0..maxN,0..maxN] of char;

Procedure mo;
Begin
        Assign(fi,fin); Reset(fi);
        Assign(fo,fon); Rewrite(fo);
End;

Procedure dong;
Begin
        Close(fi);
        Close(fo);
End;

Procedure nhap;
Var
	i,j:longint;
        c:char;
Begin
        For i:=1 to 3 do
        Begin
                For j:=1 to 3 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=4 to 6 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=7 to 9 do
                Read(fi,a[i,j]);
                Readln(fi);
        End;
        Readln(fi);

        For i:=4 to 6 do
        Begin
                For j:=1 to 3 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=4 to 6 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=7 to 9 do
                Read(fi,a[i,j]);
                Readln(fi);
        End;
        Readln(fi);

        For i:=7 to 9 do
        Begin
                For j:=1 to 3 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=4 to 6 do
                Read(fi,a[i,j]);
                Read(fi,c);
                For j:=7 to 9 do
                Read(fi,a[i,j]);
                Readln(fi);
        End;
        Readln(fi,x,y);
End;

Procedure xuly;
Var
        i,j:longint;
        sua:boolean;
Begin
        sua:=false;
        For i:=mang[x]*3 downto mang[x]*3-2 do
        For j:=mang[y]*3 downto mang[y]*3-2 do
        If a[i,j]='.' then
        Begin
                a[i,j]:='!';
                sua:=true;
        End;

        If not sua then
        For i:=1 to 9 do
        For j:=1 to 9 do
        If a[i,j]='.' then a[i,j]:='!';
End;

Procedure xuat;
Var
        i,j:longint;
Begin
        For i:=1 to 3 do
        Begin
                For j:=1 to 3 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=4 to 6 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=7 to 9 do
                Write(fo,a[i,j]);
                Writeln(fo);
        End;
        Writeln(fo);

        For i:=4 to 6 do
        Begin
                For j:=1 to 3 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=4 to 6 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=7 to 9 do
                Write(fo,a[i,j]);
                Writeln(fo);
        End;
        Writeln(fo);

        For i:=7 to 9 do
        Begin
                For j:=1 to 3 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=4 to 6 do
                Write(fo,a[i,j]);
                Write(fo,' ');
                For j:=7 to 9 do
                Write(fo,a[i,j]);
                Writeln(fo);
        End;
End;

BEGIN
        Mo;
        Nhap;
        Xuly;
        Xuat;
        Dong;
END.

{$coperators on}
{$mode objfpc}
const
        fi='INPUT.INP';
        fo='OUTPUT.OUT';
procedure fileio;
begin
        assign(input,fi); reset(input);
        assign(output,fo); rewrite(output);
end;
var     a,s:array[0..11] of string;
        x,y:longint;
procedure enter;
var     i,j:longint;
begin
        for i:=1 to 3 do begin
                for j:=1 to 3 do
                        readln(s[(i-1)*3+j]);
                if (i<>3) then
                readln;
        end;
        for i:=1 to 9 do begin
                for j:=1 to 11 do
                        if s[i][j]<>#32 then
                                a[i]+=s[i][j];
        end;
        readln(X,y);
end;
procedure solve;
var     bl:boolean;
        i,j:longint;
begin
        x:=x mod 3;
        y:=y mod 3;
        if x=0 then x:=3;
        if y=0 then y:=3;
        bl:=false;
        for i:=(x-1)*3+1 to x*3 do
         for j:=(y-1)*3+1 to y*3 do
          if a[i][j]='.' then begin
                bl:=true;
                a[i][j]:='!';
          end;
        if not bl then begin
                for i:=1 to 9 do
                 for j:=1 to 9 do
                  if a[i][j]='.' then a[i][j]:='!';
        end;
        for i:=1 to 3 do begin
                for j:=1 to 3 do begin
                        for x:=1 to 3 do begin
                                for y:=1 to 3 do
                                        write(a[(i-1)*3+j][(x-1)*3+y]);
                                write(#32);
                        end;
                        writeln;
                end;
                writeln;
        end;
end;
begin
        //fileio;
        enter;
        solve;
end.

const fin='';
      fout='';
var s:array[1..11]of string;
    x,y,i,j:longint;
procedure enter;
var i,j:longint;
begin
    for i:=1 to 3 do
      begin
          for j:=1 to 3 do
            begin
                readln(s[(i-1)*3+j]);
                delete(s[(i-1)*3+j],4,1);
                delete(s[(i-1)*3+j],7,1);
            end;
          if(i<3) then readln;
      end;
    readln(x,y);
end;
function chk(x,y:longint):boolean;
var i,j:longint;
begin
    for i:=1 to 3 do
      for j:=1 to 3 do
        begin
            if(s[(x-1)*3+i][(y-1)*3+j]='.') then exit(true);
        end;
    exit(false);
end;
begin
    assign(input,fin);reset(input);
    assign(output,fout);rewrite(output);
    enter;
    x:=x mod 3;
    if(x=0) then x:=3;
    y:=y mod 3;
    if(y=0) then y:=3;
    if(chk(x,y)) then
      begin
          for i:=1 to 3 do
            for j:=1 to 3 do
              begin
                  if(s[(x-1)*3+i][(y-1)*3+j]='.') then s[(x-1)*3+i][(y-1)*3+j]:='!';
              end;
      end else
      begin
          for i:=1 to 9 do
            for j:=1 to 9 do
              if(s[i][j]='.') then s[i][j]:='!';
      end;
    for i:=1 to 3 do
      begin
          for j:=1 to 3 do
            begin
                insert(' ',s[(i-1)*3+j],4);
                insert(' ',s[(i-1)*3+j],8);
                writeln(s[(i-1)*3+j]);
            end;
          writeln;
      end;
    close(input);
    close(output);
end.

var
b:array[1..9]of string;
s:string;
i,j,x,y,xx,yy,sc,t,tt:integer;

begin

for i:=1 to 11 do begin
  readln(s);
  if length(s)>0 then begin
  inc(j);
  b[j]:=s;
  delete(b[j],4,1);
  delete(b[j],7,1);
  end;
  end;
readln(x,y);

xx:=y mod 3;
if xx=0 then xx:=3;
yy:=x mod 3;
if yy=0 then yy:=3;

for i:=(xx-1)*3+1 to (xx-1)*3+3 do
  for j:=(yy-1)*3+1 to (yy-1)*3+3 do begin

    if b[j][i]='.' then begin
        b[j][i]:='!';
        inc(sc);
        end;
        end;
t:=0;
if sc<>0 then
  for i:=1 to 11 do
  if (i=4) or (i=8) then writeln() else begin
  inc(t);
  insert(' ',b[t],4);
  insert(' ',b[t],8);
  writeln(b[t])
    end
  else begin
  for i:=1 to 9 do for j:=1 to 9 do
  if b[i][j]='.' then b[i][j]:='!';

  for i:=1 to 11 do
  if (i=4) or (i=8)  then writeln() else begin
  inc(t);
  insert(' ',b[t],4);
  insert(' ',b[t],8);
  writeln(b[t])
  end;
  end;

end.

        const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

function good(ch:char):boolean;
begin
  if (ord(ch)>20)and(ord(ch)<220) then good:=true else good:=false;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    n:=11; m:=11;
    for i:=1 to n do
      begin readln(ss);
        m:=length(ss);
        for j:=1 to m do pole[i,j]:=ss[j];

      end;
    read(aa,bb);

   { for i:=1 to n do begin  for j:=1 to m do write(pole[i,j]); writeln; end;
    }
    ii:=aa+(aa-1) div 3;
    jj:=bb+(bb-1) div 3;

               for i:=1 to n do for j:=1 to m  do pole1[i,j]:=pole[i,j];

  {  writeln(aa,' ',bb);
    writeln(ii,'  ii jj ',jj);
   }
    p1:=(aa-1) mod 3+1;
    p2:=(bb-1) mod 3+1;
   { writeln(p1,'  p1,p2 ',p2);
    }flag:=false;
    for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1  do if pole[i,j]='.' then flag:=true;

   { writeln(flag);
    }
    if flag then
      begin
         ii:=(aa-1) mod 3+1;
         jj:=(bb-1) mod 3+1;

       {  writeln(ii,' ==  ',jj);
        }
         for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do
           if pole[i,j]='.' then pole1[i,j]:='!';

         for i:=1 to n do begin  for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;
             goto 1;

      end;

      if not flag then
        begin
           for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';
            for i:=1 to n do begin  for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;
             goto 1;

        end;

   1:    close(output);
end.

var
  k, nPos, x, y  : longint;

  sVsp,
  sNotUsed, s1, s2, s3  : string;

  arrStr  : array [1..9] of string;

{********************************************}
function ModifyStr (inpStr : string) : string;
var
  tmpModifyStr : string;
begin
  tmpModifyStr:= inpStr;
  if (x = 1) or (x = 4) or (x = 7)
  then begin
         if tmpModifyStr [1] = '.'
         then tmpModifyStr [1]:= '!';
         if tmpModifyStr [2] = '.'
         then tmpModifyStr [2]:= '!';
         if tmpModifyStr [3] = '.'
         then tmpModifyStr [3]:= '!';
       end;

  if (x = 2) or (x = 5) or (x = 8)
  then begin
         if tmpModifyStr [5] = '.'
         then tmpModifyStr [5]:= '!';
         if tmpModifyStr [6] = '.'
         then tmpModifyStr [6]:= '!';
         if tmpModifyStr [7] = '.'
         then tmpModifyStr [7]:= '!';
       end;

  if (x = 3) or (x = 6) or (x = 9)
  then begin
         if tmpModifyStr [9] = '.'
         then tmpModifyStr [9]:= '!';
         if tmpModifyStr [10] = '.'
         then tmpModifyStr [10]:= '!';
         if tmpModifyStr [11] = '.'
         then tmpModifyStr [11]:= '!';
       end;
  ModifyStr:= tmpModifyStr;
end;
{********************************************}

{***************************** MAIN PROGRAM *****************************}
begin
  readln (arrStr [1]);
  readln (arrStr [2]);
  readln (arrStr [3]);
  readln (sNotUsed);
  readln (arrStr [4]);
  readln (arrStr [5]);
  readln (arrStr [6]);
  readln (sNotUsed);
  readln (arrStr [7]);
  readln (arrStr [8]);
  readln (arrStr [9]);
  readln (y, x);

  if (y = 1) or (y = 4) or (y = 7)
  then begin
         s1:= arrStr [1];
         s2:= arrStr [2];
         s3:= arrStr [3];
       end;

  if (y = 2) or (y = 5) or (y = 8)
  then begin
         s1:= arrStr [4];
         s2:= arrStr [5];
         s3:= arrStr [6];
       end;

  if (y = 3) or (y = 6) or (y = 9)
  then begin
         s1:= arrStr [7];
         s2:= arrStr [8];
         s3:= arrStr [9];
       end;

  if (x = 1) or (x = 4) or (x = 7)
  then sVsp:= s1 [1] + s1 [2] + s1 [3] + s2 [1] + s2 [2] + s2 [3] + s3 [1] + s3 [2] + s3 [3];

  if (x = 2) or (x = 5) or (x = 8)
  then sVsp:= s1 [5] + s1 [6] + s1 [7] + s2 [5] + s2 [6] + s2 [7] + s3 [5] + s3 [6] + s3 [7];

  if (x = 3) or (x = 6) or (x = 9)
  then sVsp:= s1 [9] + s1 [10] + s1 [11] + s2 [9] + s2 [10] + s2 [11] + s3 [9] + s3 [10] + s3 [11];

  if (pos ('.', sVsp) = 0)
  then begin
         for k:= 1 to 9
         do begin
              for nPos:= 1 to 11
              do if (arrStr [k][nPos] = '.')
                 then arrStr [k][nPos]:= '!';
              writeln (arrStr [k]);
              if (k mod 3 = 0)
              then writeln;
            end;
         Halt;
       end;

  if (y = 1) or (y = 4) or (y = 7)
  then begin  // modify arrStr [1], arrStr [2], arrStr [3]
         arrStr [1]:= ModifyStr (arrStr [1]);
         arrStr [2]:= ModifyStr (arrStr [2]);
         arrStr [3]:= ModifyStr (arrStr [3]);
       end;

  if (y = 2) or (y = 5) or (y = 8)
  then begin  // modify arrStr [4], arrStr [5], arrStr [6]
         arrStr [4]:= ModifyStr (arrStr [4]);
         arrStr [5]:= ModifyStr (arrStr [5]);
         arrStr [6]:= ModifyStr (arrStr [6]);
       end;

  if (y = 3) or (y = 6) or (y = 9)
  then begin  // modify arrStr [7], arrStr [8], arrStr [9]
         arrStr [7]:= ModifyStr (arrStr [7]);
         arrStr [8]:= ModifyStr (arrStr [8]);
         arrStr [9]:= ModifyStr (arrStr [9]);
       end;

  for k:= 1 to 9
  do begin
      writeln (arrStr [k]);
      if (k mod 3 = 0)
      then writeln;
    end;

//  readln;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
      for j:=1 to 11 do
      read(a[i,j]);
      readln;
    end;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln;
    end;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln;
    end;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4=0 then readln else
    begin
    for j:=1 to 11 do
    read(a[i,j]);
    readln;
    end;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln(' ');
    end;
    writeln;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln(' ');
    end;
    writeln;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4=0 then readln else
    begin
    for j:=1 to 11 do
    read(a[i,j]);
    readln;
    end;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln(' ');
    end;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln(' ');
    end;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
    for j:=1 to 11 do
    read(a[i,j]);
    readln;
    end;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln(' ');
    end;
    writeln;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln(' ');
    end;
    writeln;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
      for j:=1 to 11 do
      read(a[i,j]);
    end;
    readln;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln;
    end;
    writeln;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln;
    end;
    writeln;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
      for j:=1 to 11 do
      read(a[i,j]);
      readln;
    end;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln(' ');
    end;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln(' ');
    end;
end.

var a: array [1..11,1..11] of char;
    x,y,i,j,n,m,k: byte;
begin
 n:=0; m:=0; k:=0;
 for i:=1 to 11 do begin
  for j:=1 to 11 do
   read(a[i,j]);
  readln;
  end;
 read(x,y);
 if x<4 then n:=1; if x>6 then n:=9; if n=0 then n:=5;
 if y<4 then m:=1; if y>6 then m:=9; if m=0 then m:=5;
 for i:=y to y+2 do
  for j:=x to x+2 do
   if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;
 if k=0 then
  for i:=1 to 11 do
   for j:=1 to 11 do
    if a[i,j]='.' then a[i,j]:='!';
 end.

var a: array [1..11,1..11] of char;
    x,y,i,j,n,m,k: byte;
begin
 n:=0; m:=0; k:=0;
 for i:=1 to 11 do begin
  for j:=1 to 11 do
   read(a[i,j]);
  readln;
  end;
 read(x,y);
 if x<4 then n:=1; if x>6 then n:=9; if n=0 then n:=5;
 if y<4 then m:=1; if y>6 then m:=9; if m=0 then m:=5;
 for i:=y to y+3 do
  for j:=x to x+3 do
   if a[i,j]='.' then begin a[i,j]:='!'; k:=1; end;
 if k=0 then
  for i:=1 to 11 do
   for j:=1 to 11 do
    if a[i,j]='.' then a[i,j]:='!';
 end.

program qq;
var a: array [1..9,1..9] of char;
c: char;
x,y,j,m,p:integer;
begin
j:=1;
while j<=9 do begin
 m:=1;
while m<=9 do begin
read (c);
if (c='.') or (c='x') or (c='o') then begin a[j,m]:=c; m:=m+1; end;
end;
j:=j+1 end;
read (x,y);
j:= 3*(x mod 3)-2; m:= 3*(y mod 3) - 2;
if j=-2 then j:=7; if m=-2 then m:=7; p:=0;
for i:integer:=j to j+2 do
for n:integer:=m to m+2 do
if a[i,n]='.' then begin p:=1; a[i,n]:='!'; end;
if p=0 then
for i:integer:=1 to 9 do
for n:integer:=1 to 9 do if a[i,n]='.' then a[i,n]:='!';
for i:integer:=1 to 9 do begin
writeln ();
if i=4 then writeln (); if i=7 then writeln ();
for n:integer:=1 to 9 do begin
if n=4 then write (' '); if n=7 then write (' ');
write (a[i,n]);
end;
end;
end.

var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;
  begin
  for i:=1 to 9 do
    begin
     readln(s);
     for l:=1 to 11 do
      begin
       if (l=4) or (l=8) then continue;
       if (l>4) and (l<8) then u:=l-1;
       if (l>8) then u:=l-2;
       if (l<4) then u:=l;
       a[i, u]:=s[l];
      end;
    if (i<9) and (i mod 3 = 0 ) then readln(s);
    end;
   read(x,y);
   if a[x,y]='o' then chir:='x' else chir:='o';
   flag:=true;
   if x mod 3 = 0 then
   line:=3;
   if x mod 3 = 2 then
    line:=2;
   if x mod 3 = 1 then
   line:=1;
   if y mod 3 = 0 then
   col:=3;
   if y mod 3 = 2 then
   col:=2;
   if y mod 3 = 1 then
   col:=1;
   for i:=line*3-2 to line*3 do
   for j:=col*3-2 to col*3 do
   if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;
   if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';
 for i:=1 to 9 do
    begin
    for j:=1 to 3 do
      begin
        for l:=j*3-2 to j*3 do write(a[i, l], ' ');
      end;
    writeln;
    if (i<9) and (i mod 3 = 0 ) then writeln;
    end;

 end.

var i,j,l:integer; a:array[1..9, 1..9] of char; u:integer; s:string; x, y:integer; chir:char; line, col:integer; flag:boolean;
  begin
  for i:=1 to 9 do
    begin
     readln(s);
     for l:=1 to 11 do
      begin
       if (l=4) or (l=8) then continue;
       if (l>4) and (l<8) then u:=l-1;
       if (l>8) then u:=l-2;
       if (l<4) then u:=l;
       a[i, u]:=s[l];
      end;
    if (i<9) and (i mod 3 = 0 ) then readln(s);
    end;
   read(x,y);
   if a[x,y]='o' then chir:='x' else chir:='o';
   flag:=true;
   if x mod 3 = 0 then
   line:=3;
   if x mod 3 = 2 then
    line:=2;
   if x mod 3 = 1 then
   line:=1;
   if y mod 3 = 0 then
   col:=3;
   if y mod 3 = 2 then
   col:=2;
   if y mod 3 = 1 then
   col:=1;
   for i:=line*3-2 to line*3 do
   for j:=col*3-2 to col*3 do
   if a[i,j]='.' then begin a[i,j]:='!'; flag:=false; end;
   if flag then for i:=1 to 9 do for j:=1 to 9 do if a[i,j]='.' then a[i, j]:='!';
 for i:=1 to 9 do
    begin
    for j:=1 to 3 do
      begin
        for l:=j*3-2 to j*3 do write(a[i, l], ' ');
      end;
    writeln;

    end;

 end.

Program CodeF_454_B;
var x,y,i,j,i1,j1,n:longint;
    m:array[1..1]of longint;
    //reb:array[1..1]of array[1..2]of longint;
    p:array[0..8]of array[0..8]of longint;
    s:string;
    mogu:boolean;

begin
i1:=-1;
for i:=1 to 11 do
  begin
  readln(s);
  if length(s)=11 then
    begin
    inc(i1);
    j1:=-1;
    for j:=1 to 11 do
      begin
      if s[j]<>' ' then inc(j1);
      if s[j]='o' then
        begin
        p[i1][j1]:=1;
        end;
      if s[j]='x' then
        begin
        p[i1][j1]:=2;
        end;
      end;
    end;
  end;
read(x, y);
x:=(x-1) mod 3;
y:=(y-1) mod 3;
mogu:=false;
for i:=0 to 8 do
  for j:=0 to 8 do
    if (i div 3=x) and (j div 3=y) then
    begin
    if p[i][j]=0 then
      mogu:=true;
    end;

if mogu=true then
  for i:=0 to 8 do
    for j:=0 to 8 do
      begin
      if p[i][j]=0 then
         if (i div 3=x) and (j div 3=y) then
        p[i][j]:=3;
      end else
  begin
  for i:=0 to 8 do
    for j:=0 to 8 do
      if p[i][j]=0 then
        p[i][j]:=3;
  end;

for i:=0 to 8 do
  begin
  writeln;
  if (i mod 3=0) and (i<>0) then
    writeln;
  for j:=0 to 8 do
    begin
    if (j mod 3=0) and (j<>0) then
      write(' ');
    if p[i][j]=0 then write('.');
    if p[i][j]=1 then write('o');
    if p[i][j]=2 then write('x');
    if p[i][j]=3 then write('!');
    end;

  end;

end.

Program CodeF_454_B;
var x,y,i,j,i1,j1,n:longint;
    m:array[1..1]of longint;
    //reb:array[1..1]of array[1..2]of longint;
    p:array[0..8]of array[0..8]of longint;
    s:string;
    mogu:boolean;

begin
i1:=-1;
for i:=1 to 11 do
  begin
  readln(s);
  if length(s)=11 then
    begin
    inc(i1);
    j1:=-1;
    for j:=1 to 11 do
      begin
      if s[j]<>' ' then inc(j1);
      if s[j]='o' then
        begin
        p[i1][j1]:=1;
        end;
      if s[j]='x' then
        begin
        p[i1][j1]:=2;
        end;
      end;
    end;
  end;
read(x, y);
x:=(x-1) mod 3;
y:=(y-1) mod 3;
mogu:=false;
for i:=0 to 8 do
  for j:=0 to 8 do
    if (i div 3=x) and (j div 3=y) then
    begin
    if p[i][j]=0 then
      mogu:=true;
    end;

if mogu=true then
  for i:=0 to 8 do
    for j:=0 to 8 do
      begin
      if p[i][j]=0 then
         if (i div 3=x) and (j div 3=y) then
        p[i][j]:=3;
      end else
  begin
  for i:=0 to 8 do
    for j:=0 to 8 do
      if p[i][j]=0 then
        p[i][j]:=3;
  end;

for i:=0 to 8 do
  begin
  writeln;
  if (i mod 3=0) and (i<>0) then
    writeln;
  for j:=0 to 8 do
    begin
    if (j mod 3=0) and (j<>0) then
      write(' ');
    if p[i][j]=0 then write('.');
    if p[i][j]=1 then write('o');
    if p[i][j]=2 then write('x');
    if p[i][j]=3 then write('!');
    end;
writeln;

  end;

end.

var
  big: array[1..9, 1..9] of integer;
  strs: array[1..9] of string;
  k, num, x, y, i, j, x1, x2, y1, y2: integer;
  ch: char;
  s: string;

begin

  for i := 1 to 9 do
  begin

    k := -1; j := 1;
    while (j <= 9) do
    begin
      read(ch);
      if (ch = 'x')  then k := 1;
      if(ch = 'o') then k := 2;
      if(ch = '.') then k := 0;
      if(k >= 0) then
      begin
        big[i, j] := k;
        inc(j);
      end;
      k := -1;
    end;

  end;
  read(y, x);

  x := x mod 3;
  y := y mod 3;
  if(x = 1) then
  begin
    x1 := 1;
    x2 := 3;
  end else
  if(x = 2) then
  begin
    x1 := 4;
    x2 := 6;
  end else
  begin
    x1 := 7;
    x2 := 9;
  end;
  if(y = 1) then
  begin
    y1 := 1;
    y2 := 3;
  end else
  if(y = 2) then
  begin
    y1 := 4;
    y2 := 6;
  end else
  begin
    y1 := 7;
    y2 := 9;
  end;
  num := 0;
  for i := y1 to y2 do
    for j := x1 to x2 do
    begin
      if(big[i, j] = 0) then
        inc(num);
    end;

  if(num = 0) then begin
    x1 := 1;
    x2 := 9;
    y1 := 1;
    y2 := 9;
  end;
  for i := 1 to 9 do
  begin
    s := '';
    for j := 1 to 9 do
    begin
      if(big[i, j] = 1) then
        s += 'x';
      if(big[i, j] = 2) then s += 'o';
      if(big[i, j] = 0) then
      begin
        if(i <= y2 ) and (i >= y1) and (j <= x2) and (j >= x1) then
          s += '!' else s += '.';
      end;
      if(j mod 3 = 0) then s += ' ';

    end;
    writeln(s);
  end;

end.

var
  a: array [1..11, 1..11] of char;
  i, j, n, m, k: integer;
  isNotFull: boolean;

begin
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      readln();
      continue;
    end;
    for j := 1 to 11 do read(a[i, j]);
    readln();
  end;
  read(n, m);
  isNotFull := false;
  if (n >= 4) and (n <= 6) then n += 1;
  if (m >= 4) and (m <= 6) then m += 1;
  if (n >= 8) and (n <= 9) then n += 2;
  if (m >= 8) and (m <= 9) then m += 2;
  if (n = 1) or (n = 5) or (n = 9) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 1 to 3 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 1 to 3 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 1 to 3 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 2) or (n = 6) or (n = 10) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 5 to 7 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 5 to 7 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 5 to 7 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 3) or (n = 7) or (n = 11) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 9 to 11 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 9 to 11 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 9 to 11 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if isNotFull = false then for i := 1 to 11 do
      for j := 1 to 11 do
        if a[i, j] = '.' then a[i, j] := '!';
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      writeln();
      continue;
    end;
    for j := 1 to 11 do write(a[i, j]);
    writeln();
  end;
end.

var
  a: array [1..11, 1..11] of char;
  i, j, n, m, k: integer;
  isNotFull: boolean;

begin
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      readln();
      continue;
    end;
    for j := 1 to 11 do read(a[i, j]);
    readln();
  end;
  read(n, m);
  isNotFull := false;
  if (n >= 4) and (n <= 6) then n += 1;
  if (m >= 4) and (m <= 6) then m += 1;
  if (n >= 7) and (n <= 9) then n += 2;
  if (m >= 7) and (m <= 9) then m += 2;
  if (n = 1) or (n = 5) or (n = 9) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 1 to 3 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 1 to 3 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 1 to 3 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 1 to 3 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 2) or (n = 6) or (n = 10) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 5 to 7 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 5 to 7 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 5 to 7 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 5 to 7 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if (n = 3) or (n = 7) or (n = 11) then begin
    if (m = 1) or (m = 5) or (m = 9) then begin
      for i := 9 to 11 do
        for j := 1 to 3 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 1 to 3 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 2) or (m = 6) or (m = 10) then begin
      for i := 9 to 11 do
        for j := 5 to 7 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 5 to 7 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
    if (m = 3) or (m = 7) or (m = 11) then begin
      for i := 9 to 11 do
        for j := 9 to 11 do
          if a[i, j] = '.' then isNotFull := true;
      if isNotFull = true then
        for i := 9 to 11 do
          for j := 9 to 11 do
            if a[i, j] = '.' then a[i, j] := '!';
    end;
  end;
  if isNotFull = false then for i := 1 to 11 do
      for j := 1 to 11 do
        if a[i, j] = '.' then a[i, j] := '!';
  for i := 1 to 11 do
  begin
    if (i = 4) or (i = 8) then begin
      writeln();
      continue;
    end;
    for j := 1 to 11 do write(a[i, j]);
    writeln();
  end;
end.

var i,j,xx,yy,x:longint;c:char;f:boolean;
a,b:array[0..1000,0..1000]of char;
procedure p(x:longint);
var i:longint;
begin
for i:=1 to 3 do
  if a[x,i]='.' then write('!')
  else write(a[x,i]);
write(' ');
for i:=4 to 6 do
  if a[x,i]='.' then write('!')
  else write(a[x,i]);
write(' ');
for i:=7 to 9 do
  if a[x,i]='.' then write('!')
  else write(a[x,i]);
if(x=3)or(x=6)then writeln;
if x<>9 then writeln;
end;
procedure pp(x:longint);
var i:longint;
begin
for i:=1 to 3 do write(a[x,i]);
write(' ');for i:=4 to 6 do write(a[x,i]);
write(' ');for i:=7 to 9 do write(a[x,i]);
write(' ');
if(x=3)or(x=6)then writeln;
if x<>9 then writeln;
end;
begin
//assign(input,'tictactoe.in');reset(input);
//assign(output,'tictactoe.out');rewrite(output);
for i:=1 to 11 do
  begin
  if(i<>4)and(i<>8)then
    begin
    inc(x);for j:=1 to 3 do read(a[x,j]);
    read(c);for j:=4 to 6 do read(a[x,j]);
    read(c);for j:=7 to 9 do read(a[x,j]);
    end;readln;
  end;
readln(xx,yy);xx:=(xx-1)mod 3+1;yy:=(yy-1)mod 3+1;
f:=true;
for i:=(xx-1)*3+1 to xx*3 do
  for j:=(yy-1)*3+1 to yy*3 do
    if a[i,j]<>'.' then f:=false;
if not f then
  begin
  for i:=1 to 9 do p(i);
  end
else
  begin
  for i:=(xx-1)*3+1 to xx*3 do
    for j:=(yy-1)*3+1 to yy*3 do
      a[i,j]:='!';
  for i:=1 to 9 do pp(i);
  end;
close(input);close(output);
end.

var a:array[0..1000]of string;
x,y,i,j:longint;f:boolean;
begin
//assign(input,'tictactoe.in');reset(input);
//assign(output,'tictactoe.out');rewrite(output);
for I:=1 to 9 do
  begin
  if(i=4)or(i=7)then readln(a[i]);
  readln(a[i]);
  delete(a[i],8,1);
  delete(a[i],4,1);
  end;
read(x,y);
x:=(x-1)mod 3+1;
y:=(y-1)mod 3+1;
f:=true;
for i:=(x-1)*3+1 to x*3 do
  for j:=(y-1)*3+1 to y*3 do
    if a[i,j]<>'.' then
      f:=false;
if not f then
  begin
  for i:=1 to 9 do
    for j:=1 to 9 do
      if a[i,j]='.' then a[i,j]:='!';
  end
else
  for i:=(x-1)*3+1 to x*3 do
    for j:=(y-1)*3+1 to y*3 do
      if a[i,j]='.' then
        a[i,j]:='!';
for i:=1 to 9 do
  begin
  for j:=1 to 9 do
    begin
    write(a[i,j]);
    if(j=3)or(j=6)then write(' ');
    end;
  writeln;
  if(i=3)or(i=6)then writeln;
  end;
close(input);close(output);
end.

{$coperators on}
{$mode objfpc}
const
        fi='INPUT.INP';
        fo='OUTPUT.OUT';
procedure fileio;
begin
        assign(input,fi); reset(input);
        assign(output,fo); rewrite(output);
end;
var     a,s:array[0..11] of string;
        x,y:longint;
procedure enter;
var     i,j:longint;
begin
        for i:=1 to 3 do begin
                for j:=1 to 3 do
                        readln(s[(i-1)*3+j]);
                if (i<>3) then
                readln;
        end;
        for i:=1 to 9 do begin
                for j:=1 to 11 do
                        if s[i][j]<>#32 then
                                a[i]+=s[i][j];
        end;
        readln(X,y);
end;
procedure solve;
var     bl:boolean;
        i,j:longint;
begin
        x:=x mod 3;
        y:=y mod 3;
        if x=0 then x:=3;
        if y=0 then y:=3;
        bl:=false;
        for i:=(x-1)*3+1 to x*3 do
         for j:=(y-1)*3+1 to y*3 do
          if a[i][j]='.' then begin
                bl:=true;
                a[i][j]:='!';
          end;
        if not bl then begin
                for i:=1 to 9 do
                 for j:=1 to 9 do
                  if a[i][j]='.' then a[i][j]:='!';
        end;
        for i:=1 to 3 do begin
                for j:=1 to 3 do begin
                        for x:=1 to 3 do begin
                                for y:=1 to 3 do
                                        write(a[(i-1)*3+j][(x-1)*3+y]);
                                write(#32);
                        end;
                        writeln;
                end;
        end;
end;
begin
        //fileio;
        enter;
        solve;
end.

var i,j,x,y,z,c:longint;
    a:array[0..20,0..20]of char;
    now:array[0..20,0..20]of longint;
    ch:char;
    can:boolean;
begin
  for i:=1 to 11 do
  begin
    if i mod 4<>0 then
    begin
      for j:=1 to 11 do
      read(a[i,j]);
    end;
    readln;
  end;
  readln(x,y);
  if x>6 then inc(x,2) else
  if x>3 then inc(x,1);
  if y>6 then inc(y,2) else
  if y>3 then inc(y,1);
  for i:=(x mod 4)*4-3 to (x mod 4)*4-1 do
  begin
    for j:=(y mod 4)*4-3 to (y mod 4)*4-1 do
    if a[i,j]='.' then
    begin
      can:=true;
      a[i,j]:='!';
    end;
  end;
  if not can then
  begin
    for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      if a[i,j]='.' then write('!') else
      write(a[i,j]);
      writeln;
    end;
    exit;
  end;
  for i:=1 to 11 do
    begin
      for j:=1 to 11 do
      write(a[i,j]);
      writeln;
    end;
end.

var
b:array[1..9]of string;
s:string;
i,j,x,y,xx,yy,sc,t,tt:integer;
begin
for i:=1 to 11 do begin
  readln(s);
  if length(s)>0 then begin
  inc(j);
  b[j]:=s;
  delete(b[j],4,1);
  delete(b[j],7,1);
  end;
  end;
readln(x,y);
xx:=y mod 3;
if xx=0 then xx:=3;
yy:=x mod 3;
if yy=0 then yy:=3;

for i:=(xx-1)*3+1 to (xx-1)*3+3 do
  for j:=(yy-1)*3+1 to (yy-1)*3+3 do begin

    if b[j][i]='.' then begin
        b[j][i]:='!';
        inc(sc);
        end;
        end;
if sc<>0 then
  for i:=1 to 9 do
  writeln(b[i])
  else begin
  for i:=1 to 9 do for j:=1 to 9 do
  if b[i][j]='.' then b[i][j]:='!';

  for i:=1 to 9 do
  writeln(b[i])
  end;

end.

          const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    n:=11; m:=11;
    for i:=1 to n do
      begin readln(ss);
        m:=length(ss);
        for j:=1 to m do pole[i,j]:=ss[j];

      end;
    read(aa,bb);

   { for i:=1 to n do begin  for j:=1 to m do write(pole[i,j]); writeln; end;
    }
    ii:=aa+(aa-1) div 3;
    jj:=bb+(bb-1) div 3;

               for i:=1 to n do for j:=1 to m  do pole1[i,j]:=pole[i,j];

  {  writeln(aa,' ',bb);
    writeln(ii,'  ii jj ',jj);
   }
    p1:=(aa-1) mod 3+1;
    p2:=(bb-1) mod 3+1;
   { writeln(p1,'  p1,p2 ',p2);
    }flag:=false;
    for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1  do if pole[i,j]='.' then flag:=true;

   { writeln(flag);
    }
      inc(m);
    if flag then
      begin
         ii:=(aa-1) mod 3+1;
         jj:=(bb-1) mod 3+1;

       {  writeln(ii,' ==  ',jj);
        }
         for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do
           if pole[i,j]='.' then pole1[i,j]:='!';

         for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

      end;

      if not flag then
        begin
           for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';
             for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

        end;

   1:    close(output);
end.

        const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

function good(ch:char):boolean;
begin
  if (ord(ch)>20)and(ord(ch)<120) then good:=true else good:=false;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    n:=11; m:=11;
    for i:=1 to n do
      begin readln(ss);
        m:=length(ss);
        for j:=1 to m do pole[i,j]:=ss[j];

      end;
    read(aa,bb);

   { for i:=1 to n do begin  for j:=1 to m do write(pole[i,j]); writeln; end;
    }
    ii:=aa+(aa-1) div 3;
    jj:=bb+(bb-1) div 3;

               for i:=1 to n do for j:=1 to m  do pole1[i,j]:=pole[i,j];

  {  writeln(aa,' ',bb);
    writeln(ii,'  ii jj ',jj);
   }
    p1:=(aa-1) mod 3+1;
    p2:=(bb-1) mod 3+1;
   { writeln(p1,'  p1,p2 ',p2);
    }flag:=false;
    for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1  do if pole[i,j]='.' then flag:=true;

   { writeln(flag);
    }
    if flag then
      begin
         ii:=(aa-1) mod 3+1;
         jj:=(bb-1) mod 3+1;

       {  writeln(ii,' ==  ',jj);
        }
         for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do
           if pole[i,j]='.' then pole1[i,j]:='!';

         for i:=1 to n do begin  for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;
             goto 1;

      end;

      if not flag then
        begin
           for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';
            for i:=1 to n do begin  for j:=1 to m do if good(pole[i,j]) then write(pole1[i,j]) else write(' '); writeln; end;
             goto 1;

        end;

   1:    close(output);
end.

          const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    n:=11; m:=11;
    for i:=1 to n do
      begin readln(ss);
        m:=length(ss);
        for j:=1 to m do pole[i,j]:=ss[j];

      end;
    read(aa,bb);

   { for i:=1 to n do begin  for j:=1 to m do write(pole[i,j]); writeln; end;
    }
    ii:=aa+(aa-1) div 3;
    jj:=bb+(bb-1) div 3;

               for i:=1 to n do for j:=1 to m  do pole1[i,j]:=pole[i,j];

  {  writeln(aa,' ',bb);
    writeln(ii,'  ii jj ',jj);
   }
    p1:=(aa-1) mod 3+1;
    p2:=(bb-1) mod 3+1;
   { writeln(p1,'  p1,p2 ',p2);
    }flag:=false;
    for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1  do if pole[i,j]='.' then flag:=true;

   { writeln(flag);
    }
    if flag then
      begin
         ii:=(aa-1) mod 3+1;
         jj:=(bb-1) mod 3+1;

       {  writeln(ii,' ==  ',jj);
        }
         for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do
           if pole[i,j]='.' then pole1[i,j]:='!';

         for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

      end;

      if not flag then
        begin
           for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';
             for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

        end;

   1:    close(output);
end.

          const eps=0.000000001;  besk=20000000000008;
               modul=1000000007;
   label 1,2,3,4,5,6;
    type
    mas=array [-100..1000000] of int64;   point=record x,y,z,vx,vy,vz:int64;end;
    zap=record p1,p2,p3 :int64;end; zap1=^zap; point1=^point;
    mass=array[-100..1000000] of int64;mass1=^mass;
    var t4,left,right,gr,xx,yy,sum,ogr,jloz,jnew,i1,i2,i3,maxdob,nn,kk,pos1,pos2,start,ans,pp,qq,aaa,bbb,ccc,tt,aa,bb,jj,ii,ott,time,ppp,istart,jstart,iii,newdl, t1,t2,cc,ll,rr,oldpos,t,jjj,kol,pos,dloch,told,p,q,pmin,ppold,ot,pmax,imax,p1,p2,p3,p4,l,nm,n,s2,m,smin,cen:int64;
   mask,k, step, i,j:longint;
   pointnew,pointold,pointklad,ppoint:point;
    vot,distmin,hh,dist,s0,s1,aanew,bbnew:extended;
    mm,mx,my,mz,tr,maxright,fact,aold,y,och,s,d11,prev,next,z,x,newc,d,nap:array[-10..2000008] of int64;
    a,b,c:mass;
    sd:array[-1000..1000000] of char;
    yyy:array[-10..10000] of extended;
    dot,ddd:array[-10..1210000] of int64;
    ddminus, ppole:array[-1..200,-10..150,-1..150] of int64;
   sss,text1,text2:array[-10..2000000] of string;
   zanxy,zanxz,zanyz:array[-1..200,-1..200] of boolean;
     ss,stest,ss3,ss1,ss2:string;
     ch1,ch2:char;
     traf,dd1,dd:array[-1..5000,-1..5000] of int64;
     zan,zana,zanb:array[-10..2000000] of boolean;
     marked:array[-100..15000] of boolean;
    {sss:string;ch:char;
   } pole1,pole :array [-10..150,-10..150] of char;
    st:array[-100..100000] of string;
     v0,v1,t0:extended;
     zv:point;
     newx,newy:array[-1..200000] of int64;

     koef,yot:extended;
      globflag, flag2,flag,flag1:boolean;
    function al(x,y:extended):extended; var t0,t1,p,s0,s1:extended;
 begin
     if (x>0)and(y>=0) then p:=arctan(y/x);
     if x<0 then p:=pi+arctan(y/x);
     if(x>0)and(y<0) then p:=2*pi+arctan(y/x);
     if x=0 then if (y>=0) then p:=pi/2 else p:=3*pi/2;
     al:=p/pi*180;
 end;
  function min(x,y:int64):int64;begin min:=x;if y<x then min:=y; end;
  function max(x,y:int64):int64;begin max:=x;if y>x then max:=y; end;

  function nod(x,y:int64):int64; var z:int64;
begin   repeat  z:=x mod y;x:=y;y:=z;   until  z=0 ;  nod:=x;end;

{procedure udal(ii:longint);
begin  next[prev[ii]]:=next[ii]; prev[next[ii]]:=prev[ii];  end;
 }
function degg(a,k:int64):int64; var p:int64;
begin
 if k<=0 then degg:=1 else if odd(k) then degg:=degg(a,k-1)*a mod modul else
   begin  p:=degg(a,k div 2); degg:=p*p mod modul;   end;

end;

begin
   { assign (input,'input.txt');reset(input);
      assign (output,'output.txt'); rewrite(output);
    }
    n:=11; m:=11;
    for i:=1 to n do
      begin readln(ss);
        m:=length(ss);
        for j:=1 to m do pole[i,j]:=ss[j];

      end;
    read(aa,bb);

   { for i:=1 to n do begin  for j:=1 to m do write(pole[i,j]); writeln; end;
    }
    ii:=aa+(aa-1) div 3;
    jj:=bb+(bb-1) div 3;

               for i:=1 to n do for j:=1 to m  do pole1[i,j]:=pole[i,j];

  {  writeln(aa,' ',bb);
    writeln(ii,'  ii jj ',jj);
   }
    p1:=(aa-1) mod 3+1;
    p2:=(bb-1) mod 3+1;
   { writeln(p1,'  p1,p2 ',p2);
    }flag:=false;
    for i:=4*p1-3 to 4*p1-1 do for j:=4*p2-3 to 4*p2-1  do if pole[i,j]='.' then flag:=true;

   { writeln(flag);
    }
      inc(n);inc(m);
    if flag then
      begin
         ii:=(aa-1) mod 3+1;
         jj:=(bb-1) mod 3+1;

       {  writeln(ii,' ==  ',jj);
        }
         for i:=4*ii-3 to 4*ii-1 do for j:=4*jj-3 to 4*jj-1 do
           if pole[i,j]='.' then pole1[i,j]:='!';

         for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

      end;

      if not flag then
        begin
           for i:=1 to n do for j:=1 to m do if pole[i,j]='.' then pole1[i,j]:='!';
             for i:=1 to n do begin  for j:=1 to m do write(pole1[i,j]); writeln; end;
             goto 1;

        end;

   1:    close(output);
end.