#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j;
  vector<string> c;
  for (i = 0; i < 6; i++) {
    string s;
    cin >> s;
    c.push_back(s);
  }
  vector<pair<long long, long long> > vp;
  vp.push_back(make_pair(0, 3));
  vp.push_back(make_pair(0, 4));
  vp.push_back(make_pair(1, 3));
  vp.push_back(make_pair(1, 4));
  vp.push_back(make_pair(0, 0));
  vp.push_back(make_pair(0, 1));
  vp.push_back(make_pair(1, 0));
  vp.push_back(make_pair(1, 1));
  vp.push_back(make_pair(2, 3));
  vp.push_back(make_pair(2, 4));
  vp.push_back(make_pair(3, 3));
  vp.push_back(make_pair(3, 4));
  vp.push_back(make_pair(0, 6));
  vp.push_back(make_pair(0, 7));
  vp.push_back(make_pair(1, 6));
  vp.push_back(make_pair(1, 7));
  vp.push_back(make_pair(2, 0));
  vp.push_back(make_pair(2, 1));
  vp.push_back(make_pair(3, 0));
  vp.push_back(make_pair(3, 1));
  vp.push_back(make_pair(4, 3));
  vp.push_back(make_pair(4, 4));
  vp.push_back(make_pair(5, 3));
  vp.push_back(make_pair(5, 4));
  vp.push_back(make_pair(2, 6));
  vp.push_back(make_pair(2, 7));
  vp.push_back(make_pair(3, 6));
  vp.push_back(make_pair(3, 7));
  vp.push_back(make_pair(4, 0));
  vp.push_back(make_pair(4, 1));
  vp.push_back(make_pair(5, 0));
  vp.push_back(make_pair(5, 1));
  vp.push_back(make_pair(4, 6));
  vp.push_back(make_pair(4, 7));
  vp.push_back(make_pair(5, 6));
  vp.push_back(make_pair(5, 7));
  long long p, q;
  for (i = 0; i < 36; i++) {
    p = vp[i].first;
    q = vp[i].second;
    if (c[p][q] == '.') {
      break;
    }
  }
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 8; j++) {
      if (i == p and j == q)
        cout << 'P';
      else
        cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}
