using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Problem904B
{
    class Program
    {
        static bool ChkSquare(int[,] g, int i, int j)
        {
            i = i / 3 * 3;
            j = j / 3 * 3;
            for (int x = i; x < i + 3; x++)
                for (int y = j; y < j + 3; y++)
                {
                    if (g[x, y] == 0)
                        return true;
                }
            return false;
        }

        static void Main(string[] args)
        {
            int[,] g = new int[9, 9];
            for (int i = 0; i < 9; i++)
            {
                string s = Console.ReadLine().Trim();
                if (s == "")
                {
                    i--; continue;
                }
                for (int j = 0, k = 0; j < 9; j++, k++)
                {
                    if (s[k] == ' ')
                    {
                        j--; continue;
                    }
                    switch(s[k])
                    {
                        case 'x':
                            g[j, i] = 1;
                            break;
                        case 'o':
                            g[j, i] = 2;
                            break;
                        default:
                            g[j, i] = 0;
                            break;
                    }
                }
            }
            int[] lx = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToArray();
            bool f = ChkSquare(g, (lx[1] - 1) % 3 * 3, (lx[0] - 1) % 3 * 3);
            if (!f)
            {
                for (int i = 0; i < 9; i++)
                    for (int j = 0; j < 9; j++)
                        if (g[i, j] == 0)
                            g[i, j] = 3;
            }
            else
            {
                int x = (lx[1] - 1) % 3 * 3, y = (lx[0] - 1) % 3 * 3;
                for (int i = x; i < x + 3; i++)
                    for (int j = y; j < y + 3; j++)
                    {
                        if (g[i, j] == 0)
                            g[i, j] = 3;
                    }
            }

            for (int j = 0; j < 9; j++)
            {
                for (int i = 0; i < 9; i++)
                {
                    if (i != 0 && i % 3 == 0)
                        Console.Write(" ");
                    switch (g[i, j])
                    {
                        case 0:
                            Console.Write(".");
                            break;
                        case 1:
                            Console.Write("x");
                            break;
                        case 2:
                            Console.Write("o");
                            break;
                        case 3:
                            Console.Write("!");
                            break;
                    }
                }
                if (j + 1 != 0 && (j + 1) % 3 == 0)
                    Console.WriteLine();
                Console.WriteLine();
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      var f = new char[9][];
      ReadField(f);
      var x = input.ReadInt() - 1;
      var y = input.ReadInt() - 1;
      var fx = x % 3;
      var fy = y % 3;
      if (!TryFillField(f, fx, fy))
        FillAll(f);
      PrintField(f);
    }

    private void ReadField(char[][] f)
    {
      for (int i = 0; i < 9; i++)
      {
        if (i != 0 && i % 3 == 0)
          input.ReadLine();
        f[i] = string.Join("", input.ReadLine().Split()).ToCharArray();
      }
    }

    private void PrintField(char[][] f)
    {
      var sb = new StringBuilder();
      for (int i = 0; i < 9; i++)
      {
        if (i != 0 && i % 3 == 0)
          sb.AppendLine();
        for (int j = 0; j < 9; j++)
        {
          if (j != 0 && j % 3 == 0)
            sb.Append(' ');
          sb.Append(f[i][j]);
        }
        sb.AppendLine();
      }
      Console.Write(sb);
    }

    private void FillAll(char[][] f)
    {
      for (int i = 0; i < 9; i++)
        for (int j = 0; j < 9; j++)
          if (f[i][j] == '.')
            f[i][j] = '!';
    }

    private bool TryFillField(char[][] f, int fx, int fy)
    {
      bool result = false;
      for (int i = 0; i < 3; i++)
      {
        for (int j = 0; j < 3; j++)
        {
          int lx = fx * 3 + i;
          int ly = fy * 3 + j;
          if (f[lx][ly] == '.')
          {
            f[lx][ly] = '!';
            result = true;
          }
        }
      }
      return result;
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }

    #region Service functions

    private const string ABC = "abcdefghijklmnopqrstuvwxyz";

    private static void AddCount<T>(Dictionary<T, int> counter, T item)
    {
      int count;
      if (counter.TryGetValue(item, out count))
        counter[item] = count + 1;
      else
        counter.Add(item, 1);
    }

    private static int GetCount<T>(Dictionary<T, int> counter, T item)
    {
      int count;
      return counter.TryGetValue(item, out count) ? count : 0;
    }

    private static int GCD(int a, int b)
    {
      while (b != 0)
      {
        a %= b;
        int t = b;
        b = a;
        a = t;
      }
      return a;
    }

    #endregion
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public string ReadToEnd()
    {
      return this.reader.ReadToEnd();
    }

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(this.ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using System.Numerics;
using System.Diagnostics;

namespace ConsoleApplication1
{

    class Set<T> : SortedSet<T>
    {
    }

    class Program
    {

        static TextReader sr;
        static TextWriter sw;
        static Random rnd = new Random();

        enum Direction { Vertical, Horizontal }

        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                sr = new StreamReader("input.txt");
                sw = new StreamWriter("output.txt");
            }
            else
            {
                sr = Console.In;
                sw = Console.Out;
            }
            Solve();
            if (File.Exists("input.txt"))
            {
                sr.Close();
                sw.Close();
            }
        }

        static void Solve()
        {
            char[,] a = new char[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    string temp = ReadString();
                    while (temp == "")
                        temp = ReadString();
                    for (int td = 0; td < 3; td++)
                    {
                        a[i, j * 3 + td] = temp[td];
                    }
                }
            }

            int x = ReadInt() - 1, y = ReadInt() - 1;

            int kx = x % 3;
            int ky = y % 3;

            bool f = false;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    f |= (a[kx * 3 + i, ky * 3 + j] == '.');
                }
            }

            if (f)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (a[kx * 3 + i, ky * 3 + j] == '.')
                            a[kx * 3 + i, ky * 3 + j] = '!';
                    }
                }
            }
            else
            {
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        if (a[ i, j] == '.')
                            a[i, j] = '!';
                    }
                }
            }

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int td = 0; td < 3; td++)
                    {
                        sw.Write(a[i, j * 3 + td]);
                    }
                    sw.Write(" ");
                }
                sw.WriteLine();
                if (i % 3 == 2)
                    sw.WriteLine();
            }
        }

        static long getManhattan(Pair<long, long> a, Pair<long, long> b)
        {
            return Math.Abs(a.first - b.first) + Math.Abs(a.second - b.second);
        }

        static double getArithmeticProgressionSum(int n)
        {
            return (n * (n + 1)) / 2;
        }

        static string[] buffer = new string[0];
        static int counterbuffer = 0;

        static Graph ReadGraph()
        {
            return ReadGraph(ReadInt(), ReadInt());
        }

        static Graph ReadGraph(int n, int m)
        {
            int[] a = new int[m];
            int[] b = new int[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
            }
            return new Graph(n, a, b);
        }

        static Graph<T> ReadGraph<T>(Parser<T> parser)
            where T : IComparable<T>
        {
            int n = ReadInt();
            int m = ReadInt();
            int[] a = new int[m];
            int[] b = new int[m];
            T[] c = new T[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
                c[i] = Read<T>(sr, parser);
            }
            return new Graph<T>(n, a, b, c);
        }

        static int[] ReadArrayInt()
        {
            return sr.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int[] ReadArrayInt(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }

        static long[] ReadArrayLong()
        {
            return sr.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static int[][] ReadMatrixInt(int n, int m)
        {
            int[][] answer = new int[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new int[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadInt();
                }
            }
            return answer;
        }

        static long[][] ReadMatrixLong(int n, int m)
        {
            long[][] answer = new long[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new long[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadLong();
                }
            }
            return answer;
        }

        static char[][] ReadMatrixChar(int n, int m)
        {
            char[][] answer = new char[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = ReadString().ToCharArray();
            }
            return answer;
        }

        static BigInteger ReadBigInteger()
        {
            return ReadBigInteger(sr);
        }

        static BigInteger ReadBigInteger(TextReader sr)
        {
            return Read<BigInteger>(sr, BigInteger.Parse);
        }

        static int ReadInt()
        {
            return ReadInt(sr);
        }

        static int ReadInt(TextReader sr)
        {
            return Read<int>(sr, int.Parse);
        }

        static long ReadLong()
        {
            return ReadLong(sr);
        }

        static long ReadLong(TextReader sr)
        {
            return Read<long>(sr, long.Parse);
        }

        static double ReadDouble()
        {
            return ReadDouble(sr);
        }

        static double ReadDouble(TextReader sr)
        {
            return Read<double>(sr, double.Parse);
        }

        static string ReadString()
        {
            return ReadString(sr);
        }

        static string ReadString(TextReader sr)
        {
            return Read<string>(sr, x => x);
        }

        static U Read<U>(TextReader sr, Parser<U> parser)
        {
            if (counterbuffer >= buffer.Length)
            {
                buffer = sr.ReadLine().Split(' ').ToArray();
                while (buffer.Length == 0)
                {
                    buffer = sr.ReadLine().Split(' ').ToArray();
                }
                counterbuffer = 0;
            }
            return parser(buffer[counterbuffer++]);
        }
    }

    public delegate U Parser<U>(string str);

    class Graph
    {
        protected int[][] Edges;
        public int this[int val1, int val2]
        {
            get
            {
                return Edges[val1][val2];
            }
            set
            {
                Edges[val1][val2] = value;
            }
        }

        public int GetLength()
        {
            return Edges.Length;
        }

        public int GetLength(int n)
        {
            return Edges[n].Length;
        }

        public Graph(int n, int[] a, int[] b)
        {
            generateEdges(n, a, b);
        }

        private void generateEdges(int n, int[] a, int[] b)
        {
            int[] temp = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    temp[a[i] - 1]++;
                    temp[b[i] - 1]++;
                }
                else
                {
                    temp[a[i] - 1]++;
                }
            }
            Edges = new int[n][];
            for (int i = 0; i < n; i++)
            {
                Edges[i] = new int[temp[i]];
            }
            for (int i = 0; i < n; i++)
            {
                temp[i] = 0;
            }
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                    Edges[b[j] - 1][temp[b[j] - 1]++] = a[j] - 1;
                }
                else
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            foreach (var i in Edges)
            {
                foreach (var j in i)
                {
                    answer += (j + 1) + " ";
                }
                answer += Environment.NewLine;
            }
            return answer;
        }
    }

    class Graph<T> : Graph
        where T : IComparable<T>
    {
        public T[][] Cost;
        public Graph(int n, int[] a, int[] b, T[] c) : base(n, a, b)
        {
            this.GenerateEdges(n, a, b, c);
        }

        private void GenerateEdges(int n, int[] a, int[] b, T[] c)
        {
            Cost = new T[n][];
            for (int i = 0; i < n; i++)
            {
                Cost[i] = new T[Edges[i].Length];
            }
            int[] temp = new int[n];

            for (int j = 0; j < c.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                    Cost[b[j] - 1][temp[b[j] - 1]++] = c[j];
                }
                else
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            for (int i = 0; i < Cost.Length; i++)
            {
                for (int j = 0; j < Cost[i].Length; j++)
                {
                    answer += (i + 1) + " " + (Edges[i][j] + 1) + " " + Cost[i][j] + Environment.NewLine;
                }
            }
            return answer;
        }
    }

    class SimplePair<U, V>
    {
        public U first;
        public V second;
        public SimplePair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

    }

    class Pair<U, V> : IComparable<Pair<U, V>>
        where U : IComparable<U>
        where V : IComparable<V>
    {
        public U first;
        public V second;
        public Pair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

        public int CompareTo(Pair<U, V> b)
        {
            if (first.CompareTo(b.first) == 0)
            {
                return second.CompareTo(b.second);
            }
            return first.CompareTo(b.first);
        }
    }

    class SuperList<T>
    {
        protected LinkedList<T> linkedListMain;
        protected LinkedList<SimplePair<int, LinkedListNode<T>>> linkedListAdditional;
        int step = 0;
        public int resize = 0;

        public SuperList(IEnumerable<T> input)
        {
            Init(input);
        }

        public int Count { get { return linkedListMain.Count; } }

        public T this[int index]
        {
            get
            {
                return GetNode(index).Value;
            }
            set
            {
                GetNode(index).Value = value;
            }
        }

        public void AddValueToIndex(int index, T value)
        {
            if (index > linkedListMain.Count || index < 0)
            {
                throw new IndexOutOfRangeException();
            }
            if (index == linkedListMain.Count)
            {
                linkedListMain.AddLast(value);
                linkedListAdditional.Last.Value.second = linkedListMain.Last;
                linkedListAdditional.Last.Value.first = linkedListMain.Count - 1;
                IncreaseReferenceIndexes(index + 1);
                return;
            }
            if (index == 0)
            {
                linkedListMain.AddFirst(value);
                linkedListAdditional.First.Value.second = linkedListMain.First;
                IncreaseReferenceIndexes(1);
                return;
            }
            linkedListMain.AddBefore(GetNode(index), value);
            IncreaseReferenceIndexes(index);
        }

        private LinkedListNode<T> GetNode(int index)
        {
            var NowNode = linkedListAdditional.First;
            while (NowNode != linkedListAdditional.Last
                && NowNode.Value.first < index)
            {
                NowNode = NowNode.Next;
            }
            var NodeAnswer = NowNode.Value.second;
            int i = NowNode.Value.first;
            while (i > index)
            {
                i--;
                NodeAnswer = NodeAnswer.Previous;
            }
            while (i < index)
            {
                i++;
                NodeAnswer = NodeAnswer.Next;
            }
            return NodeAnswer;
        }

        private void Init(IEnumerable<T> input)
        {
            linkedListMain = new LinkedList<T>();
            foreach (T iter in input)
            {
                linkedListMain.AddLast(iter);
            }
            InitReferences();
        }

        private void InitReferences()
        {
            resize++;
            linkedListAdditional = new LinkedList<SimplePair<int, LinkedListNode<T>>>();
            step = Math.Max(1, (int)Math.Sqrt(linkedListMain.Count));
            int now = step;
            LinkedListNode<T> NowNode = null;
            for (int i = 0; i < linkedListMain.Count; i++)
            {
                if (NowNode == null)
                    NowNode = linkedListMain.First;
                else
                    NowNode = NowNode.Next;
                if (now == step)
                {
                    now = 0;
                    linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>(i, NowNode));
                }
                else
                {
                    now++;
                }
            }
            if (linkedListMain.Last != linkedListAdditional.Last.Value.second)
            {
                linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>
                    (linkedListMain.Count - 1, linkedListMain.Last));
            }
        }

        private void IncreaseReferenceIndexes(int BeginIndex)
        {
            if (linkedListMain.Count == 2)
            {
                InitReferences();
                return;
            }
            LinkedListNode<SimplePair<int, LinkedListNode<T>>> NowNode = null;
            int maxstep = 0;
            for (int i = 0; i < linkedListAdditional.Count; i++)
            {
                if (NowNode == null)
                {
                    NowNode = linkedListAdditional.First;
                }
                else
                {
                    NowNode = NowNode.Next;
                }
                if (NowNode.Value.first >= BeginIndex)
                {
                    NowNode.Value.first++;
                }
                if (NowNode.Previous != null)
                {
                    maxstep = Math.Max(maxstep, NowNode.Value.first - NowNode.Previous.Value.first);
                }
            }
            if (maxstep > step * 2)
            {
                InitReferences();
            }
        }

        public override string ToString()
        {
            return String.Join(" ", linkedListMain);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

namespace _904B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[,][,] matrix = new int[3, 3][,];
            for (int i = 0; i < 3; i++)
                for (int j = 0; j < 3; j++)
                    matrix[i, j] = new int[3, 3];
            for (int Y = 0; Y < 3; Y++)
            {
                for (int y = 0; y < 3; y++)
                {
                    string[] line = Console.ReadLine().Split(' ');
                    for (int X = 0; X < 3; X++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            matrix[X, Y][x, y] = line[X][x] == '.' ? 0 : (line[X][x] == 'x' ? 1 : 2);
                        }
                    }
                }
                if (Y != 2)
                    Console.ReadLine();
            }
            string[] lastLine = Console.ReadLine().Split(' ');
            int lastY = int.Parse(lastLine[0]) - 1, lastX = int.Parse(lastLine[1]) - 1;
            int posX = lastX % 3, posY = lastY % 3;
            List<Tuple<int, int>> found = new List<Tuple<int, int>>();
            for (int x = 0; x < 3; x++)
                for (int y = 0; y < 3; y++)
                    if (matrix[posX,posY][x,y] == 0)
                        found.Add(new Tuple<int, int>(x, y));
            if (found.Count == 0)
            {
                for (int X = 0; X < 3; X++)
                    for (int Y = 0; Y < 3; Y++)
                        for (int x = 0; x < 3; x++)
                            for (int y = 0; y < 3; y++)
                            {
                                if (matrix[X, Y][x, y] == 0)
                                    matrix[X, Y][x, y] = 10;
                            }
            }
            else
            {
                foreach (var p in found)
                    matrix[posX, posY][p.Item1, p.Item2] = 10;
            }
            var sb = new StringBuilder();
            for (int Y = 0; Y < 3; Y++)
            {
                for (int y = 0; y < 3; y++)
                {
                    for (int X = 0; X < 3; X++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            switch (matrix[X, Y][x, y])
                            {
                                case 0:
                                    sb.Append('.');
                                    break;
                                case 1:
                                    sb.Append('x');
                                    break;
                                case 2:
                                    sb.Append('o');
                                    break;
                                case 10:
                                    sb.Append('!');
                                    break;
                            }
                        }
                        if (X != 2)
                            sb.Append(' ');
                    }
                    sb.AppendLine();
                }
                if (Y != 2)
                    sb.AppendLine();
            }
            Console.Write(sb);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Tic_Tac_Toe
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            Solve(args);
            writer.Flush();
        }

        private static void Solve(string[] args)
        {
            var nn = new int[9,9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    nn[i, j] = Next();
                }
            }

            int x = (Next() - 1)%3;
            int y = (Next() - 1)%3;

            x *= 3;
            y *= 3;
            bool f = false;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (nn[x + i, y + j] == 0)
                    {
                        f = true;
                        nn[x + i, y + j] = 2;
                    }
                }
            }

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    if (j == 3 || j == 6)
                        writer.Write(' ');
                    switch (nn[i, j])
                    {
                        case 0:
                            writer.Write(f ? '.' : '!');
                            break;
                        case 1:
                            writer.Write('x');
                            break;
                        case -1:
                            writer.Write('o');
                            break;
                        case 2:
                            writer.Write('!');
                            break;
                    }
                }
                writer.WriteLine();
                if (i == 2 || i == 5)
                    writer.WriteLine();
            }
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == '.')
                    return 0;
                if (c == 'x')
                    return 1;
                if (c == 'o')
                    return -1;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Codeforces.NET
{
    class Table
    {
        List<List<char>> Components { get; set; }
    }
    class Program
    {
        private static void WriteFull(List<string> values)
        {
            for (int i = 0; i < 9; i++)
            {
                for(int j = 0; j < 9; j++)
                {
                    if (values[i][j] == '.')
                    {
                        Console.Write('!');
                    }
                    else Console.Write(values[i][j]);
                    if (j== 2 || j == 5)
                    {
                        Console.Write(' ');
                    }
                }
                if (i == 2 || i == 5)
                {
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            List<string> lines = new List<string>();
            string line = null;
            for (int i = 0; i < 11; i++)
            {
                line = Console.ReadLine();
                if (line != string.Empty)
                {
                    line = line.Replace(" ", "");
                    lines.Add(line);
                }
            }

            line = Console.ReadLine();
            int x = line.Split(' ').Select(xx => int.Parse(xx)).ToArray()[0];
            int y = line.Split(' ').Select(xx => int.Parse(xx)).ToArray()[1];

            int linie = x % 3;
            if (linie == 0) linie = 3;
            int coloana = y % 3;
            if (coloana == 0) coloana = 3;
            if (linie == 1 && coloana == 1)
            {
                bool isFull = true;
                for (int i = 1; i<=3; i++)
                {
                    for (int j = 1; j<=3; j++)
                    {
                        if (lines[i-1][j-1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }

                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i<=9; i++)
                {
                    for (int j = 1; j<=9; j++)
                    {
                        if (lines[i-1][j-1] != '.')
                        {
                            Console.Write(lines[i-1][j-1]);
                        }
                        else
                        {
                            if (i >= 1 && i <= 3 && j >= 1 && j <= 3)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();
                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 1 && coloana == 2)
            {
                bool isFull = true;
                for (int i = 1; i <= 3; i++)
                {
                    for (int j = 4; j <= 6; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 1 && i <= 3 && j >= 4 && j <= 6)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);

                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6)
                    {
                        Console.WriteLine();
                    }

                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 1 && coloana == 3)
            {
                bool isFull = true;
                for (int i = 1; i <= 3; i++)
                {
                    for (int j = 7; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 1 && i <= 3 && j >= 7 && j <= 9)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);

                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();

                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 2 && coloana == 1)
            {
                bool isFull = true;
                for (int i = 4; i <= 6; i++)
                {
                    for (int j = 1; j <= 3; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 4 && i <= 6 && j >= 1 && j <= 3)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }

                    if (i == 3 || i == 6) Console.WriteLine();

                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 2 && coloana == 2)
            {
                bool isFull = true;
                for (int i = 4; i <= 6; i++)
                {
                    for (int j = 4; j <= 6; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 4 && i <= 6 && j >= 4 && j <= 6)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();

                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 2 && coloana == 3)
            {
                bool isFull = true;
                for (int i = 4; i <= 6; i++)
                {
                    for (int j = 7; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 4 && i <= 6 && j >= 7 && j <= 9)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();
                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 3 && coloana == 1)
            {
                bool isFull = true;
                for (int i = 7; i <= 9; i++)
                {
                    for (int j = 1; j <= 3; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 7 && i <= 9 && j >= 1 && j <= 3)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();
                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else if (linie == 3 && coloana == 2)
            {
                bool isFull = true;
                for (int i = 7; i <= 9; i++)
                {
                    for (int j = 4; j <= 6; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 7 && i <= 9 && j >= 4 && j <= 6)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();
                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            else
            {
                bool isFull = true;
                for (int i = 7; i <= 9; i++)
                {
                    for (int j = 7; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] == '.')
                        {
                            isFull = false;
                            break;
                        }
                    }
                }
                if (isFull)
                {
                    WriteFull(lines);
                    Console.ReadLine();
                    return;

                }

                for (int i = 1; i <= 9; i++)
                {
                    for (int j = 1; j <= 9; j++)
                    {
                        if (lines[i - 1][j - 1] != '.')
                        {
                            Console.Write(lines[i - 1][j - 1]);
                        }
                        else
                        {
                            if (i >= 7 && i <= 9 && j >= 7 && j <= 9)
                            {
                                Console.Write('!');
                            }
                            else Console.Write(lines[i - 1][j - 1]);
                        }
                        if (j == 3 || j == 6) Console.Write(' ');
                    }
                    if (i == 3 || i == 6) Console.WriteLine();
                    Console.WriteLine();
                }

                Console.ReadLine();
                return;
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Linq;

namespace ConsProg
{
    class Program
    {
        static void Main(string[] args)
        {
            char[,] fields = new char[9, 9];
            int counter = 0, counter1 = 0;
            for(int i = 0; i < 9; i++)
            {
                string chars = Console.ReadLine();
                for(int k = 0; k < 11; k++)
                {
                    if (k == 3 || k == 7)
                    {
                        counter1++;
                        continue;
                    }
                    fields[i, counter] = chars[counter1];
                    counter++;
                    counter1++;
                }
                counter = 0;
                counter1 = 0;
                if (i == 2 || i == 5)
                    Console.ReadLine();
            }
            string data = Console.ReadLine();
            int x = ((int.Parse(data[0].ToString())-1)%3+1)*3-3;
            int y = ((int.Parse(data[2].ToString()) - 1) % 3 + 1) * 3 - 3;
            bool check = true;
            for (int i = x; i < x + 3; i++)
                for (int k = y; k < y + 3; k++)
                    if (fields[i, k] == '.')
                    {
                        fields[i, k] = '!';
                        check = false;
                    }
            for(int i = 0; i < 9; i++)
            {
                for(int k = 0; k < 9; k++)
                {
                    if (k == 3 || k == 6)
                        Console.Write(" ");
                    if (check)
                    {
                        if (fields[i, k] == '.')
                            Console.Write('!');
                        else
                            Console.Write(fields[i, k]);
                    }
                    else
                        Console.Write(fields[i, k]);
                }
                Console.WriteLine();
                if (i == 2 || i == 5)
                    Console.WriteLine();
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Text;

namespace TechnoCup2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] layer1 = Console.ReadLine().Split(' ');
            string[] layer2 = Console.ReadLine().Split(' ');
            string[] layer3 = Console.ReadLine().Split(' ');
            Console.ReadLine();
            string[] layer4 = Console.ReadLine().Split(' ');
            string[] layer5 = Console.ReadLine().Split(' ');
            string[] layer6 = Console.ReadLine().Split(' ');
            Console.ReadLine();
            string[] layer7 = Console.ReadLine().Split(' ');
            string[] layer8 = Console.ReadLine().Split(' ');
            string[] layer9 = Console.ReadLine().Split(' ');
            string[] coordinates = Console.ReadLine().Split(' ');
            BigField bigField = new BigField();
            bigField.fields[0, 0] = new Field(layer1[0], layer2[0], layer3[0]);
            bigField.fields[1, 0] = new Field(layer1[1], layer2[1], layer3[1]);
            bigField.fields[2, 0] = new Field(layer1[2], layer2[2], layer3[2]);

            bigField.fields[0, 1] = new Field(layer4[0], layer5[0], layer6[0]);
            bigField.fields[1, 1] = new Field(layer4[1], layer5[1], layer6[1]);
            bigField.fields[2, 1] = new Field(layer4[2], layer5[2], layer6[2]);

            bigField.fields[0, 2] = new Field(layer7[0], layer8[0], layer9[0]);
            bigField.fields[1, 2] = new Field(layer7[1], layer8[1], layer9[1]);
            bigField.fields[2, 2] = new Field(layer7[2], layer8[2], layer9[2]);

            int[] coordinatesNumeric = new int[] { Convert.ToInt32(coordinates[1]), Convert.ToInt32(coordinates[0]) };
            int[] coordinatesInternal = new int[] { coordinatesNumeric[0] % 3, coordinatesNumeric[1] % 3 };
            if (coordinatesInternal[0] == 0)
                coordinatesInternal[0] = 3;
            if (coordinatesInternal[1] == 0)
                coordinatesInternal[1] = 3;

            //int[] coordinatesExternal = new int[] { (coordinatesNumeric[0] - coordinatesInternal[0]) / 3, (coordinatesNumeric[1] - coordinatesInternal[1]) / 3 };

            if (bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].isFullBusy)
            {
                bigField.SetFullEmpty();
            }
            else
            {
                bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].SetEmpty();
            }
            for(int i = 0; i < 9; i++)
            {
                if (i % 3 == 0 && i != 0)
                    Console.WriteLine();
                Console.WriteLine(bigField.printLayer(i));
            }
            //Console.ReadKey();
        }
    }
    class Field
    {
        public int[,] busy;
        public Field(string layer1, string layer2, string layer3)
        {
            fill(layer1, layer2, layer3);
        }
        public void fill(string layer1, string layer2, string layer3)
        {
            busy = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                if (layer1[i] == 'o')
                    busy[i, 0] = 1;
                if (layer2[i] == 'o')
                    busy[i, 1] = 1;
                if (layer3[i] == 'o')
                    busy[i, 2] = 1;

                if (layer1[i] == 'x')
                    busy[i, 0] = 2;
                if (layer2[i] == 'x')
                    busy[i, 1] = 2;
                if (layer3[i] == 'x')
                    busy[i, 2] = 2;
            }
        }
        public bool isFullBusy { get
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                        if (busy[i, j] == 0)
                            return false;
                }
                return true;
            }
        }
        public void SetEmpty()
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    if (busy[i, j] == 0)
                        busy[i, j] = 3;
            }
        }
        public string printLayer(int layerNum)
        {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < 3; i++)
            {
                switch(busy[i, layerNum])
                {
                    case 1:
                        sb.Append("o");
                        break;
                    case 2:
                        sb.Append("x");
                        break;
                    case 3:
                        sb.Append("!");
                        break;
                    default:
                        sb.Append(".");
                        break;
                }
            }
            return sb.ToString();
        }

    }
    class BigField
    {
        public Field[,] fields;
        public BigField()
        {
            fields = new Field[3, 3];
        }
        public void SetFullEmpty()
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    fields[i, j].SetEmpty();
            }
        }
        public string printLayer(int layerNum)
        {
            int internalLayer = layerNum % 3;
            /*if (internalLayer == 0 && layerNum != 0)
                internalLayer = 3;*/
            layerNum = (layerNum - internalLayer) / 3;
            StringBuilder sb = new StringBuilder(0);
            for(int i = 0; i < 3; i++)
            {
                sb.Append(fields[i, layerNum].printLayer(internalLayer));
                if (i != 2)
                    sb.Append(" ");
            }
            return sb.ToString();
        }
    }
}
/*class Program
{
    static void Main(string[] args)
    {
        string length = Console.ReadLine();
        string input = Console.ReadLine();
        int changing = 0;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i <= input.Length - 2; i += 2)
        {
            if (input[i] == input[i + 1])
            {
                if (input[i] == 'a') { sb.Append(input[i] + "b"); }
                else { sb.Append(input[i] + "a"); }
                changing++;
            }
            else
                sb.Append(input[i] + "" + input[i + 1]);
        }
        Console.WriteLine(changing);
        Console.WriteLine(sb.ToString());
        Console.ReadKey();
    }
}*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using System.Numerics;
using System.Diagnostics;

namespace ConsoleApplication1
{

    class Set<T> : SortedSet<T>
    {
    }

    class Program
    {

        static TextReader sr;
        static TextWriter sw;
        static Random rnd = new Random();

        enum Direction { Vertical, Horizontal }

        static void Main(string[] args)
        {
            if (File.Exists("input.txt"))
            {
                sr = new StreamReader("input.txt");
                sw = new StreamWriter("output.txt");
            }
            else
            {
                sr = Console.In;
                sw = Console.Out;
            }
            Solve();
            if (File.Exists("input.txt"))
            {
                sr.Close();
                sw.Close();
            }
        }

        static void Solve()
        {
            char[,] a = new char[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    string temp = ReadString();
                    while (temp == "")
                        temp = ReadString();
                    for (int td = 0; td < 3; td++)
                    {
                        a[i, j * 3 + td] = temp[td];
                    }
                }
            }

            int x = ReadInt() - 1, y = ReadInt() - 1;

            int kx = x % 3;
            int ky = y % 3;

            bool f = false;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    f |= (a[kx * 3 + i, ky * 3 + j] == '.');
                }
            }

            if (f)
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        if (a[kx * 3 + i, ky * 3 + j] == '.')
                            a[kx * 3 + i, ky * 3 + j] = '!';
                    }
                }
            }
            else
            {
                for (int i = 0; i < 9; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        if (a[ i, j] == '.')
                            a[i, j] = '!';
                    }
                }
            }

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int td = 0; td < 3; td++)
                    {
                        sw.Write(a[i, j * 3 + td]);
                    }
                    sw.Write(" ");
                }
                sw.WriteLine();
            }
        }

        static long getManhattan(Pair<long, long> a, Pair<long, long> b)
        {
            return Math.Abs(a.first - b.first) + Math.Abs(a.second - b.second);
        }

        static double getArithmeticProgressionSum(int n)
        {
            return (n * (n + 1)) / 2;
        }

        static string[] buffer = new string[0];
        static int counterbuffer = 0;

        static Graph ReadGraph()
        {
            return ReadGraph(ReadInt(), ReadInt());
        }

        static Graph ReadGraph(int n, int m)
        {
            int[] a = new int[m];
            int[] b = new int[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
            }
            return new Graph(n, a, b);
        }

        static Graph<T> ReadGraph<T>(Parser<T> parser)
            where T : IComparable<T>
        {
            int n = ReadInt();
            int m = ReadInt();
            int[] a = new int[m];
            int[] b = new int[m];
            T[] c = new T[m];
            for (int i = 0; i < m; i++)
            {
                a[i] = ReadInt();
                b[i] = ReadInt();
                c[i] = Read<T>(sr, parser);
            }
            return new Graph<T>(n, a, b, c);
        }

        static int[] ReadArrayInt()
        {
            return sr.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        static int[] ReadArrayInt(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }

        static long[] ReadArrayLong()
        {
            return sr.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static int[][] ReadMatrixInt(int n, int m)
        {
            int[][] answer = new int[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new int[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadInt();
                }
            }
            return answer;
        }

        static long[][] ReadMatrixLong(int n, int m)
        {
            long[][] answer = new long[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = new long[m];
                for (int j = 0; j < m; j++)
                {
                    answer[i][j] = ReadLong();
                }
            }
            return answer;
        }

        static char[][] ReadMatrixChar(int n, int m)
        {
            char[][] answer = new char[n][];
            for (int i = 0; i < n; i++)
            {
                answer[i] = ReadString().ToCharArray();
            }
            return answer;
        }

        static BigInteger ReadBigInteger()
        {
            return ReadBigInteger(sr);
        }

        static BigInteger ReadBigInteger(TextReader sr)
        {
            return Read<BigInteger>(sr, BigInteger.Parse);
        }

        static int ReadInt()
        {
            return ReadInt(sr);
        }

        static int ReadInt(TextReader sr)
        {
            return Read<int>(sr, int.Parse);
        }

        static long ReadLong()
        {
            return ReadLong(sr);
        }

        static long ReadLong(TextReader sr)
        {
            return Read<long>(sr, long.Parse);
        }

        static double ReadDouble()
        {
            return ReadDouble(sr);
        }

        static double ReadDouble(TextReader sr)
        {
            return Read<double>(sr, double.Parse);
        }

        static string ReadString()
        {
            return ReadString(sr);
        }

        static string ReadString(TextReader sr)
        {
            return Read<string>(sr, x => x);
        }

        static U Read<U>(TextReader sr, Parser<U> parser)
        {
            if (counterbuffer >= buffer.Length)
            {
                buffer = sr.ReadLine().Split(' ').ToArray();
                while (buffer.Length == 0)
                {
                    buffer = sr.ReadLine().Split(' ').ToArray();
                }
                counterbuffer = 0;
            }
            return parser(buffer[counterbuffer++]);
        }
    }

    public delegate U Parser<U>(string str);

    class Graph
    {
        protected int[][] Edges;
        public int this[int val1, int val2]
        {
            get
            {
                return Edges[val1][val2];
            }
            set
            {
                Edges[val1][val2] = value;
            }
        }

        public int GetLength()
        {
            return Edges.Length;
        }

        public int GetLength(int n)
        {
            return Edges[n].Length;
        }

        public Graph(int n, int[] a, int[] b)
        {
            generateEdges(n, a, b);
        }

        private void generateEdges(int n, int[] a, int[] b)
        {
            int[] temp = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] != b[i])
                {
                    temp[a[i] - 1]++;
                    temp[b[i] - 1]++;
                }
                else
                {
                    temp[a[i] - 1]++;
                }
            }
            Edges = new int[n][];
            for (int i = 0; i < n; i++)
            {
                Edges[i] = new int[temp[i]];
            }
            for (int i = 0; i < n; i++)
            {
                temp[i] = 0;
            }
            for (int j = 0; j < a.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                    Edges[b[j] - 1][temp[b[j] - 1]++] = a[j] - 1;
                }
                else
                {
                    Edges[a[j] - 1][temp[a[j] - 1]++] = b[j] - 1;
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            foreach (var i in Edges)
            {
                foreach (var j in i)
                {
                    answer += (j + 1) + " ";
                }
                answer += Environment.NewLine;
            }
            return answer;
        }
    }

    class Graph<T> : Graph
        where T : IComparable<T>
    {
        public T[][] Cost;
        public Graph(int n, int[] a, int[] b, T[] c) : base(n, a, b)
        {
            this.GenerateEdges(n, a, b, c);
        }

        private void GenerateEdges(int n, int[] a, int[] b, T[] c)
        {
            Cost = new T[n][];
            for (int i = 0; i < n; i++)
            {
                Cost[i] = new T[Edges[i].Length];
            }
            int[] temp = new int[n];

            for (int j = 0; j < c.Length; j++)
            {
                if (a[j] != b[j])
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                    Cost[b[j] - 1][temp[b[j] - 1]++] = c[j];
                }
                else
                {
                    Cost[a[j] - 1][temp[a[j] - 1]++] = c[j];
                }
            }
        }

        public override string ToString()
        {
            string answer = "";
            for (int i = 0; i < Cost.Length; i++)
            {
                for (int j = 0; j < Cost[i].Length; j++)
                {
                    answer += (i + 1) + " " + (Edges[i][j] + 1) + " " + Cost[i][j] + Environment.NewLine;
                }
            }
            return answer;
        }
    }

    class SimplePair<U, V>
    {
        public U first;
        public V second;
        public SimplePair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

    }

    class Pair<U, V> : IComparable<Pair<U, V>>
        where U : IComparable<U>
        where V : IComparable<V>
    {
        public U first;
        public V second;
        public Pair(U first, V second)
        {
            this.first = first;
            this.second = second;
        }

        public int CompareTo(Pair<U, V> b)
        {
            if (first.CompareTo(b.first) == 0)
            {
                return second.CompareTo(b.second);
            }
            return first.CompareTo(b.first);
        }
    }

    class SuperList<T>
    {
        protected LinkedList<T> linkedListMain;
        protected LinkedList<SimplePair<int, LinkedListNode<T>>> linkedListAdditional;
        int step = 0;
        public int resize = 0;

        public SuperList(IEnumerable<T> input)
        {
            Init(input);
        }

        public int Count { get { return linkedListMain.Count; } }

        public T this[int index]
        {
            get
            {
                return GetNode(index).Value;
            }
            set
            {
                GetNode(index).Value = value;
            }
        }

        public void AddValueToIndex(int index, T value)
        {
            if (index > linkedListMain.Count || index < 0)
            {
                throw new IndexOutOfRangeException();
            }
            if (index == linkedListMain.Count)
            {
                linkedListMain.AddLast(value);
                linkedListAdditional.Last.Value.second = linkedListMain.Last;
                linkedListAdditional.Last.Value.first = linkedListMain.Count - 1;
                IncreaseReferenceIndexes(index + 1);
                return;
            }
            if (index == 0)
            {
                linkedListMain.AddFirst(value);
                linkedListAdditional.First.Value.second = linkedListMain.First;
                IncreaseReferenceIndexes(1);
                return;
            }
            linkedListMain.AddBefore(GetNode(index), value);
            IncreaseReferenceIndexes(index);
        }

        private LinkedListNode<T> GetNode(int index)
        {
            var NowNode = linkedListAdditional.First;
            while (NowNode != linkedListAdditional.Last
                && NowNode.Value.first < index)
            {
                NowNode = NowNode.Next;
            }
            var NodeAnswer = NowNode.Value.second;
            int i = NowNode.Value.first;
            while (i > index)
            {
                i--;
                NodeAnswer = NodeAnswer.Previous;
            }
            while (i < index)
            {
                i++;
                NodeAnswer = NodeAnswer.Next;
            }
            return NodeAnswer;
        }

        private void Init(IEnumerable<T> input)
        {
            linkedListMain = new LinkedList<T>();
            foreach (T iter in input)
            {
                linkedListMain.AddLast(iter);
            }
            InitReferences();
        }

        private void InitReferences()
        {
            resize++;
            linkedListAdditional = new LinkedList<SimplePair<int, LinkedListNode<T>>>();
            step = Math.Max(1, (int)Math.Sqrt(linkedListMain.Count));
            int now = step;
            LinkedListNode<T> NowNode = null;
            for (int i = 0; i < linkedListMain.Count; i++)
            {
                if (NowNode == null)
                    NowNode = linkedListMain.First;
                else
                    NowNode = NowNode.Next;
                if (now == step)
                {
                    now = 0;
                    linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>(i, NowNode));
                }
                else
                {
                    now++;
                }
            }
            if (linkedListMain.Last != linkedListAdditional.Last.Value.second)
            {
                linkedListAdditional.AddLast(new SimplePair<int, LinkedListNode<T>>
                    (linkedListMain.Count - 1, linkedListMain.Last));
            }
        }

        private void IncreaseReferenceIndexes(int BeginIndex)
        {
            if (linkedListMain.Count == 2)
            {
                InitReferences();
                return;
            }
            LinkedListNode<SimplePair<int, LinkedListNode<T>>> NowNode = null;
            int maxstep = 0;
            for (int i = 0; i < linkedListAdditional.Count; i++)
            {
                if (NowNode == null)
                {
                    NowNode = linkedListAdditional.First;
                }
                else
                {
                    NowNode = NowNode.Next;
                }
                if (NowNode.Value.first >= BeginIndex)
                {
                    NowNode.Value.first++;
                }
                if (NowNode.Previous != null)
                {
                    maxstep = Math.Max(maxstep, NowNode.Value.first - NowNode.Previous.Value.first);
                }
            }
            if (maxstep > step * 2)
            {
                InitReferences();
            }
        }

        public override string ToString()
        {
            return String.Join(" ", linkedListMain);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Text;

namespace TechnoCup2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] layer1 = Console.ReadLine().Split(' ');
            string[] layer2 = Console.ReadLine().Split(' ');
            string[] layer3 = Console.ReadLine().Split(' ');
            Console.ReadLine();
            string[] layer4 = Console.ReadLine().Split(' ');
            string[] layer5 = Console.ReadLine().Split(' ');
            string[] layer6 = Console.ReadLine().Split(' ');
            Console.ReadLine();
            string[] layer7 = Console.ReadLine().Split(' ');
            string[] layer8 = Console.ReadLine().Split(' ');
            string[] layer9 = Console.ReadLine().Split(' ');
            string[] coordinates = Console.ReadLine().Split(' ');
            BigField bigField = new BigField();
            bigField.fields[0, 0] = new Field(layer1[0], layer2[0], layer3[0]);
            bigField.fields[1, 0] = new Field(layer1[1], layer2[1], layer3[1]);
            bigField.fields[2, 0] = new Field(layer1[2], layer2[2], layer3[2]);

            bigField.fields[0, 1] = new Field(layer4[0], layer5[0], layer6[0]);
            bigField.fields[1, 1] = new Field(layer4[1], layer5[1], layer6[1]);
            bigField.fields[2, 1] = new Field(layer4[2], layer5[2], layer6[2]);

            bigField.fields[0, 2] = new Field(layer7[0], layer8[0], layer9[0]);
            bigField.fields[1, 2] = new Field(layer7[1], layer8[1], layer9[1]);
            bigField.fields[2, 2] = new Field(layer7[2], layer8[2], layer9[2]);

            int[] coordinatesNumeric = new int[] { Convert.ToInt32(coordinates[1]), Convert.ToInt32(coordinates[0]) };
            int[] coordinatesInternal = new int[] { coordinatesNumeric[0] % 3, coordinatesNumeric[1] % 3 };
            if (coordinatesInternal[0] == 0)
                coordinatesInternal[0] = 3;
            if (coordinatesInternal[1] == 0)
                coordinatesInternal[1] = 3;

            //int[] coordinatesExternal = new int[] { (coordinatesNumeric[0] - coordinatesInternal[0]) / 3, (coordinatesNumeric[1] - coordinatesInternal[1]) / 3 };

            if (bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].isFullBusy)
            {
                bigField.SetFullEmpty();
            }
            else
            {
                bigField.fields[coordinatesInternal[0] - 1, coordinatesInternal[1] - 1].SetEmpty();
            }
            for(int i = 0; i < 9; i++)
            {
                if (i % 3 == 0)
                    Console.WriteLine();
                Console.WriteLine(bigField.printLayer(i));
            }
            //Console.ReadKey();
        }
    }
    class Field
    {
        public int[,] busy;
        public Field(string layer1, string layer2, string layer3)
        {
            fill(layer1, layer2, layer3);
        }
        public void fill(string layer1, string layer2, string layer3)
        {
            busy = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                if (layer1[i] == 'o')
                    busy[i, 0] = 1;
                if (layer2[i] == 'o')
                    busy[i, 1] = 1;
                if (layer3[i] == 'o')
                    busy[i, 2] = 1;

                if (layer1[i] == 'x')
                    busy[i, 0] = 2;
                if (layer2[i] == 'x')
                    busy[i, 1] = 2;
                if (layer3[i] == 'x')
                    busy[i, 2] = 2;
            }
        }
        public bool isFullBusy { get
            {
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                        if (busy[i, j] == 0)
                            return false;
                }
                return true;
            }
        }
        public void SetEmpty()
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    if (busy[i, j] == 0)
                        busy[i, j] = 3;
            }
        }
        public string printLayer(int layerNum)
        {
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < 3; i++)
            {
                switch(busy[i, layerNum])
                {
                    case 1:
                        sb.Append("o");
                        break;
                    case 2:
                        sb.Append("x");
                        break;
                    case 3:
                        sb.Append("!");
                        break;
                    default:
                        sb.Append(".");
                        break;
                }
            }
            return sb.ToString();
        }

    }
    class BigField
    {
        public Field[,] fields;
        public BigField()
        {
            fields = new Field[3, 3];
        }
        public void SetFullEmpty()
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                    fields[i, j].SetEmpty();
            }
        }
        public string printLayer(int layerNum)
        {
            int internalLayer = layerNum % 3;
            /*if (internalLayer == 0 && layerNum != 0)
                internalLayer = 3;*/
            layerNum = (layerNum - internalLayer) / 3;
            StringBuilder sb = new StringBuilder(0);
            for(int i = 0; i < 3; i++)
            {
                sb.Append(fields[i, layerNum].printLayer(internalLayer));
                if (i != 2)
                    sb.Append(" ");
            }
            return sb.ToString();
        }
    }
}