module main;

import core.stdc.stdio;

char[9][6] a;

char[9][6] ud;

void print() {
  for (int i = 0; i < 6; i++) {
    printf("%s\n", &a[i]);
  }
}

int main(string[] argv) {
  ud[0] = "334433";
  ud[1] = "334433";
  ud[2] = "223322";
  ud[3] = "223322";
  ud[4] = "112211";
  ud[5] = "112211";
  
  //for (int i = 0; i < 6; i++) {
  //  printf("%s\n", &ud[i]);
  //}

  for (int i = 0; i < 6; i++) {
    scanf("%s", &a[i]);
    a[i][8] = '\0';
  }

  for (char i = '4'; i > '0'; i--) {
    for (int x = 0; x < 6; x++) {
      for (int b = 0; b < 9; b++) {
        int b2 = b - (b>1) - (b>4);
        if (a[x][b] == '.' && ud[x][b2] == i) {
          a[x][b] = 'P';
          print();
          return 0;
        }
      }
    }
  }
  

  return 0;
}