#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  char a[6][8] = {'.'}, tmp, flag = 0;
  a[0][0] = a[0][1] = a[0][6] = a[0][7] = '3';
  a[1][0] = a[1][1] = a[1][6] = a[1][7] = '3';
  a[0][3] = a[0][4] = '4';
  a[1][3] = a[1][4] = '4';
  a[2][0] = a[2][1] = a[2][6] = a[2][7] = '2';
  a[3][0] = a[3][1] = a[3][6] = a[3][7] = '2';
  a[2][3] = a[2][4] = '3';
  a[3][3] = a[3][4] = '3';
  a[4][0] = a[4][1] = a[4][6] = a[4][7] = '1';
  a[5][0] = a[5][1] = a[5][6] = a[5][7] = '1';
  a[4][3] = a[4][4] = '2';
  a[5][3] = a[5][4] = '2';
  for (i = 0; i < 6; i++)
    for (j = 0; j < 8; j++) {
      cin >> tmp;
      if (tmp != '.') a[i][j] = tmp;
    }
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 8; j++)
      if (a[i][j] == '4') {
        a[i][j] = 'P';
        flag = 1;
        break;
      }
    if (flag) break;
  }
  if (!flag)
    for (i = 0; i < 6; i++) {
      for (j = 0; j < 8; j++)
        if (a[i][j] == '3') {
          a[i][j] = 'P';
          flag = 1;
          break;
        }
      if (flag) break;
    }
  if (!flag)
    for (i = 0; i < 6; i++) {
      for (j = 0; j < 8; j++)
        if (a[i][j] == '2') {
          a[i][j] = 'P';
          flag = 1;
          break;
        }
      if (flag) break;
    }
  if (!flag)
    for (i = 0; i < 6; i++) {
      for (j = 0; j < 8; j++)
        if (a[i][j] == '1') {
          a[i][j] = 'P';
          flag = 1;
          break;
        }
      if (flag) break;
    }
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 8; j++)
      if (a[i][j] == '1' || a[i][j] == '2' || a[i][j] == '3' || a[i][j] == '4')
        cout << '.';
      else
        cout << a[i][j];
    cout << endl;
  }
  return 0;
}
