#include <bits/stdc++.h>
int main() {
  struct XX {
    int val;
    int x, y;
  };
  char arr[6][8];
  int cost[6][8];
  int x = 0;
  for (int i = 0; i < 8; i++) {
    if (i == 3 || i == 4) {
      x = 4;
    } else {
      x = 3;
    }
    x++;
    for (int j = 0; j < 6; j++) {
      if (j % 2 == 0) {
        x--;
      }
      cost[j][i] = x;
    }
  }
  struct XX r[50];
  int z = 0;
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) {
      scanf(" %c", &arr[i][j]);
      if (arr[i][j] == '.') {
        struct XX xx;
        xx.val = cost[i][j];
        xx.x = i;
        xx.y = j;
        r[z] = xx;
        z++;
      }
    }
  }
  int mx = 0;
  int xo = 0;
  int yo = 0;
  for (int i = 0; i < z; i++) {
    if (r[i].val > mx) {
      mx = r[i].val;
      xo = r[i].x;
      yo = r[i].y;
    }
  }
  arr[xo][yo] = 'P';
  for (int i = 0; i < 6; i++, printf("\n")) {
    for (int j = 0; j < 8; j++) {
      printf("%c", arr[i][j]);
    }
  }
  return 0;
}
