#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, c, d, isum = 0;
  char a[20][20], s[50];
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      cin >> a[i][j];
    }
  }
  cin >> x >> y;
  c = x % 3;
  d = y % 3;
  if (c == 0) c = 3;
  if (d == 0) d = 3;
  swap(c, d);
  if (c == 1 && d == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 1; j <= 3; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 1 && i <= 3 && j >= 1 && j <= 3) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 1 && d == 2) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 1; j <= 3; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 4 && i <= 6 && j >= 1 && j <= 3) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 1 && d == 3) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 1; j <= 3; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 7 && i <= 9 && j >= 1 && j <= 3) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 2 && d == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 4; j <= 6; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 1 && i <= 3 && j >= 4 && j <= 6) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 2 && d == 2) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 4; j <= 6; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 4 && i <= 6 && j >= 4 && j <= 6) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 2 && d == 3) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 4; j <= 6; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 7 && i <= 9 && j >= 4 && j <= 6) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 3 && d == 1) {
    for (int i = 1; i <= 3; i++) {
      for (int j = 7; j <= 9; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 1 && i <= 3 && j >= 7 && j <= 9) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 3 && d == 2) {
    for (int i = 4; i <= 6; i++) {
      for (int j = 7; j <= 9; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 4 && i <= 6 && j >= 7 && j <= 9) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
  if (c == 3 && d == 3) {
    for (int i = 7; i <= 9; i++) {
      for (int j = 7; j <= 9; j++) {
        if (a[i][j] != '.') {
          isum++;
        }
      }
    }
    if (isum == 9) {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (a[i][j] == '.')
            cout << '!';
          else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    } else {
      for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
          if (i >= 7 && i <= 9 && j >= 7 && j <= 9) {
            if (a[i][j] == '.')
              cout << '!';
            else
              cout << a[i][j];
          } else
            cout << a[i][j];
          if (j % 3 == 0) cout << " ";
        }
        if (i % 3 == 0) cout << "\n";
        cout << "\n";
      }
    }
  }
}
