A classroom in a school has six rows with 3 desks in each row. Two people can use the same desk: one sitting on the left and one sitting on the right. 

Some places are already occupied, and some places are vacant. Petya has just entered the class and wants to occupy the most convenient place. The conveniences of the places are shown on the picture: [Image] 

Here, the desks in the top row are the closest to the blackboard, while the desks in the bottom row are the furthest from the blackboard.

You are given a plan of the class, where '*' denotes an occupied place, '.' denotes a vacant place, and the aisles are denoted by '-'. 

Find any of the most convenient vacant places for Petya.


-----Input-----

The input consists of 6 lines. Each line describes one row of desks, starting from the closest to the blackboard. Each line is given in the following format: two characters, each is '*' or '.' — the description of the left desk in the current row; a character '-' — the aisle; two characters, each is '*' or '.' — the description of the center desk in the current row; a character '-' — the aisle; two characters, each is '*' or '.' — the description of the right desk in the current row. So, the length of each of the six lines is 8.

It is guaranteed that there is at least one vacant place in the classroom.


-----Output-----

Print the plan of the classroom after Petya takes one of the most convenient for him places. Mark this place with the letter 'P'. There should be exactly one letter 'P' in the plan. Petya can only take a vacant place. In all other places the output should coincide with the input.

If there are multiple answers, print any.


-----Examples-----
Input
..-**-..
..-**-..
..-..-..
..-..-..
..-..-..
..-..-..

Output
..-**-..
..-**-..
..-..-..
..-P.-..
..-..-..
..-..-..

Input
**-**-**
**-**-**
..-**-.*
**-**-**
..-..-..
..-**-..

Output
**-**-**
**-**-**
..-**-.*
**-**-**
..-P.-..
..-**-..

Input
**-**-*.
*.-*.-**
**-**-**
**-**-**
..-..-..
..-**-..

Output
**-**-*.
*.-*P-**
**-**-**
**-**-**
..-..-..
..-**-..



-----Note-----

In the first example the maximum convenience is 3.

In the second example the maximum convenience is 2.

In the third example the maximum convenience is 4.

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
n = 6
table = []
ans = []
for i in range(n):
	s = input()
	table.append(s)
ind = 0
if table[0][3] == '.':
	ans.append(table[0][:3] + 'P' + table[0][4:])
	ind = 1
elif table[0][4] == '.':
	ans.append(table[0][:4] + 'P' + table[0][5:])
	ind = 1
elif table[1][3] == '.':
	ans.append(table[0])
	ans.append(table[1][:3] + 'P' + table[1][4:])
	ind = 2
elif table[1][4] == '.':
	ans.append(table[0])
	ans.append(table[1][:4] + 'P' + table[1][5:])
	ind = 2
elif table[0][0] == '.':
	ans.append('P' + table[0][1:])
	ind = 1
elif table[0][1] == '.':
	ans.append(table[0][:1] + 'P' + table[0][2:])
	ind = 1
elif table[0][6] == '.':
	ans.append(table[0][:6] + 'P' + table[0][7:])
	ind = 1
elif table[0][7] == '.':
	ans.append(table[0][:7] + 'P')
	ind = 1
elif table[1][0] == '.':
	ans.append(table[0])
	ans.append('P' + table[1][1:])
	ind = 2
elif table[1][1] == '.':
	ans.append(table[0])
	ans.append(table[1][:1] + 'P' + table[1][2:])
	ind = 2
elif table[1][6] == '.':
	ans.append(table[0])
	ans.append(table[1][:6] + 'P' + table[1][7:])
	ind = 2
elif table[1][7] == '.':
	ans.append(table[0])
	ans.append(table[1][:7] + 'P')
	ind = 2
elif table[2][3] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2][:3] + 'P' + table[2][4:])
	ind = 3
elif table[2][4] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2][:4] + 'P' + table[2][5:])
	ind = 3
elif table[3][3] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2])
	ans.append(table[3][:3] + 'P' + table[3][4:])
	ind = 4
elif table[3][4] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2])
	ans.append(table[3][:4] + 'P' + table[3][5:])
	ind = 4
elif table[2][0] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append('P' + table[2][1:])
	ind = 3
elif table[2][1] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2][:1] + 'P' + table[2][2:])
	ind = 3
elif table[2][6] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2][:6] + 'P' + table[2][7:])
	ind = 3
elif table[2][7] == '.':
	ans.append(table[0])
	ans.append(table[1])
	ans.append(table[2][:7] + 'P')
	ind = 3
elif table[3][0] == '.':
	for i in range(0, 3):
		ans.append(table[i])
	ans.append('P' + table[3][1:])
	ind = 4
elif table[3][1] == '.':
	for i in range(0, 3):
		ans.append(table[i])
	ans.append(table[3][:1] + 'P' + table[3][2:])
	ind = 4
elif table[3][6] == '.':
	for i in range(0, 3):
		ans.append(table[i])
	ans.append(table[3][:6] + 'P' + table[3][7:])
	ind = 4
elif table[3][7] == '.':
	for i in range(0, 3):
		ans.append(table[i])
	ans.append(table[3][:7] + 'P')
	ind = 4
elif table[4][3] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append(table[4][:3] + 'P' + table[4][4:])
	ind = 5
elif table[4][4] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append(table[4][:4] + 'P' + table[4][5:])
	ind = 5
elif table[5][3] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append(table[5][:3] + 'P' + table[5][4:])
	ind = 6
elif table[5][4] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append(table[5][:4] + 'P' + table[5][5:])
	ind = 6
elif table[4][0] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append('P' + table[4][1:])
	ind = 5
elif table[4][1] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append(table[4][:1] + 'P' + table[4][2:])
	ind = 5
elif table[4][6] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append(table[4][:6] + 'P' + table[4][7:])
	ind = 5
elif table[4][7] == '.':
	for i in range(0, 4):
		ans.append(table[i])
	ans.append(table[4][:7] + 'P')
	ind = 5
elif table[5][0] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append('P' + table[5][1:])
	ind = 6
elif table[5][1] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append(table[5][:1] + 'P' + table[5][2:])
	ind = 6
elif table[5][6] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append(table[5][:6] + 'P' + table[5][7:])
	ind = 6
elif table[5][7] == '.':
	for i in range(0, 5):
		ans.append(table[i])
	ans.append(table[5][:7] + 'P')
	ind = 6
for i in range(ind, n):
	ans.append(table[i])
for i in ans:
	print(i)


n = 6
m = 8
desk = []
stat = []
stat.append('33-44-33')
stat.append('33-44-33')
stat.append('22-33-22')
stat.append('22-33-22')
stat.append('11-22-11')
stat.append('11-22-11')
for i in range(n):
	desk.append(input())
flag = 0
val = 4
while flag == 0:
	for i in range(n):
		for j in range(m):
			if desk[i][j] == '.':
				if flag == 0 and val == 4 and (stat[i][j] == '4'):
					desk[i] = desk[i][:j] + 'P' + desk[i][j + 1:]
					flag = 1
				if flag == 0 and val == 3 and (stat[i][j] == '3'):
					desk[i] = desk[i][:j] + 'P' + desk[i][j + 1:]
					flag = 1
				if flag == 0 and val == 2 and (stat[i][j] == '2'):
					desk[i] = desk[i][:j] + 'P' + desk[i][j + 1:]
					flag = 1
				if flag == 0 and val == 1 and (stat[i][j] == '1'):
					desk[i] = desk[i][:j] + 'P' + desk[i][j + 1:]
					flag = 1
	val = val - 1
for i in desk:
	print(i)


from sys import stdin
arr = [stdin.readline().strip() for i in range(6)]
price = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
best = 0
for i in range(6):
	for j in range(2, 4):
		if arr[i][j + 1] == '.':
			best = max(best, price[i][j])
	for j in range(0, 2):
		if arr[i][j] == '.':
			best = max(best, price[i][j])
	for j in range(4, 6):
		if arr[i][j + 2] == '.':
			best = max(best, price[i][j])
for i in range(6):
	for j in range(2, 4):
		if arr[i][j + 1] == '.' and price[i][j] == best:
			arr[i] = arr[i][:j + 1] + 'P' + arr[i][j + 2:]
			print('\n'.join(arr))
			return
	for j in range(0, 2):
		if arr[i][j] == '.' and price[i][j] == best:
			arr[i] = arr[i][:j] + 'P' + arr[i][j + 1:]
			print('\n'.join(arr))
			return
	for j in range(4, 6):
		if arr[i][j + 2] == '.' and price[i][j] == best:
			arr[i] = arr[i][:j + 2] + 'P' + arr[i][j + 3:]
			print('\n'.join(arr))
			return


table = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
l = []
for i in range(6):
	s = input()
	ll = []
	for c in s:
		ll.append(c)
	l.append(ll)
for k in [4, 3, 2, 1]:
	for i in range(6):
		for j in range(8):
			if table[i][j] == k and l[i][j] == '.':
				l[i][j] = 'P'
				for ll in l:
					s = ''
					for c in ll:
						s = s + c
					print(s)
				return


(a, b, x, y, m) = ([list(input()) for i in range(6)], [3, 3, 0, 4, 4, 0, 3, 3], 0, 0, 0)
for i in range(6):
	for j in range(8):
		c = b[j] - i // 2
		if a[i][j] == '.' and c > m:
			(x, y, m) = (i, j, c)
a[x][y] = 'P'
print('\n'.join((''.join(x) for x in a)))


def pr(u):
	for i in range(6):
		s = ''
		for j in range(8):
			s += u[i][j]
		print(s)
p = []
for i in range(6):
	s = input()
	p.append(list(s))
priority = [[0, 3], [0, 4], [1, 3], [1, 4], [0, 0], [0, 1], [0, 6], [0, 7], [1, 0], [1, 1], [1, 6], [1, 7], [2, 3], [2, 4], [3, 3], [3, 4], [2, 0], [2, 1], [2, 6], [2, 7], [3, 0], [3, 1], [3, 6], [3, 7], [4, 3], [4, 4], [5, 3], [5, 4], [4, 0], [4, 1], [4, 6], [4, 7], [5, 0], [5, 1], [5, 6], [5, 7]]
for a in priority:
	if p[a[0]][a[1]] == '.':
		p[a[0]][a[1]] = 'P'
		pr(p)
		break


cost = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
arr = []
ans = 0
for row in range(6):
	arr.append(input())
	for col in range(8):
		if cost[row][col] > ans and arr[row][col] == '.':
			ans = cost[row][col]
for row in range(6):
	for col in range(8):
		if cost[row][col] == ans and arr[row][col] == '.':
			arr[row] = arr[row][:col] + 'P' + arr[row][col + 1:]
			ans = -1
			break
	print(arr[row])


l = [[], [], [], [], [], []]
y = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
for i in range(6):
	s = input()
	for j in s:
		if j != '-':
			l[i].append(j)
maxm = 0
maxi = 0
maxj = 0
for i in range(6):
	for j in range(6):
		if l[i][j] == '.':
			if y[i][j] > maxm:
				maxm = y[i][j]
				maxi = i
				maxj = j
l[maxi][maxj] = 'P'
for i in range(6):
	print(l[i][0], l[i][1], '-', l[i][2], l[i][3], '-', l[i][4], l[i][5], sep='')


def good(i, j):
	x = i // 2
	y = j // 2
	return 3 - x + (y == 1)
b = [0] * 6
for i in range(6):
	b[i] = input().split('-')
	b[i] = [b[i][0][0], b[i][0][1], b[i][1][0], b[i][1][1], b[i][2][0], b[i][2][1]]
mx = 0
mi = 0
mj = 0
for i in range(6):
	for j in range(6):
		if b[i][j] == '.':
			if good(i, j) > mx:
				mx = good(i, j)
				mi = i
				mj = j
b[mi][mj] = 'P'
for i in range(6):
	print(b[i][0] + b[i][1] + '-' + b[i][2] + b[i][3] + '-' + b[i][4] + b[i][5])


variants = []
price = ((3, 4, 3), (3, 4, 3), (2, 3, 2), (2, 3, 2), (1, 2, 1), (1, 2, 1))
max_price = (0, 0, 0, 0)
class_map = []
for i in range(6):
	current_row = input().split('-')
	class_map.append(current_row)
	for (j, parta) in enumerate(current_row):
		for (n, place) in enumerate(parta):
			if place == '.' and price[i][j] > max_price[0]:
				max_price = (price[i][j], i, j, n)
(i, j, n) = max_price[1:]
to_change = class_map[i][j]
if n:
	class_map[i][j] = class_map[i][j][0] + 'P'
else:
	class_map[i][j] = 'P' + class_map[i][j][1]
for row in class_map:
	print('-'.join(row))


txt = []
a = ''
for i in range(6):
	a = input()
	txt.append(a)
b = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
max = 0
maxi = 0
maxj = 0
for i in range(6):
	for j in range(8):
		if txt[i][j] == '.':
			if b[i][j] > max:
				max = b[i][j]
				maxi = i
				maxj = j
for i in range(6):
	if i == maxi:
		print(txt[i][:maxj] + 'P' + txt[i][maxj + 1:])
		continue
	print(txt[i])


arr = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
bestX = -1
bestY = -1
bestI = -1
lines = [''] * 6
for i in range(6):
	lines[i] = input()
	cnt = 0
	for j in range(8):
		if lines[i][j] == '.':
			if bestX == -1 or arr[bestY][bestX] < arr[i][cnt]:
				(bestY, bestX, bestI) = (i, cnt, j)
		if j != 2 and j != 5:
			cnt += 1
lines[bestY] = lines[bestY][:bestI] + 'P' + lines[bestY][bestI + 1:]
for i in range(6):
	print(lines[i])


a = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
mx = 0
k = []
for i in range(6):
	s = input()
	k.append(s)
	for j in range(len(s)):
		if s[j] == '.':
			if a[i][j] > mx:
				mx = a[i][j]
				i1 = i
				i2 = j
for i in range(6):
	for j in range(8):
		if i == i1 and j == i2:
			print('P', end='')
		else:
			print(k[i][j], end='')
	print()


import sys
fin = sys.stdin
fout = sys.stdout
a = [0] * 6
for i in range(6):
	a[i] = [0] * 6
for i in range(2):
	a[i][0] = 3
	a[i][1] = 3
	a[i][2] = 4
	a[i][3] = 4
	a[i][4] = 3
	a[i][5] = 3
for i in range(2, 4):
	a[i][0] = 2
	a[i][1] = 2
	a[i][2] = 3
	a[i][3] = 3
	a[i][4] = 2
	a[i][5] = 2
for i in range(4, 6):
	a[i][0] = 1
	a[i][1] = 1
	a[i][2] = 2
	a[i][3] = 2
	a[i][4] = 1
	a[i][5] = 1
ansI = -1
ansJ = -1
max = -1
ansL = []
for i in range(6):
	s = fin.readline().strip()
	ansL.append(s)
	s = s.replace('-', '')
	for j in range(6):
		if s[j] == '.' and a[i][j] > max:
			max = a[i][j]
			ansI = i
			ansJ = j
for i in range(len(ansL)):
	cur = ansL[i]
	realJ = -1
	for j in range(len(cur)):
		if cur[j] != '-':
			realJ += 1
		if i == ansI and realJ == ansJ and (cur[j] != '-'):
			fout.write('P')
		else:
			fout.write(cur[j])
	fout.write('\n')
fin.close()
fout.close()


a = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
b = []
go = True
for i in range(6):
	b.append(input())
for x in range(4, 0, -1):
	for i in range(6):
		for j in range(6):
			if a[i][j] == x:
				if b[i][j + j // 2] == '.':
					b[i] = b[i][:j + j // 2] + 'P' + b[i][j + j // 2 + 1:]
					go = False
					break
		if not go:
			break
	if not go:
		break
[print(i) for i in b]


all = []
for i in range(6):
	all.append(''.join(input().split('-')))
good = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
m = 0
mi = [0, 0]
for i in range(6):
	for j in range(6):
		if all[i][j] == '.' and good[i][j] > m:
			m = good[i][j]
			mi = [i, j]
all[mi[0]] = all[mi[0]][:mi[1]] + 'P' + all[mi[0]][mi[1] + 1:]
for i in range(6):
	print(all[i][0] + all[i][1] + '-' + all[i][2] + all[i][3] + '-' + all[i][4] + all[i][5])


mas = [3, 3, 0, 4, 4, 0, 3, 3, 3, 3, 0, 4, 4, 0, 3, 3, 2, 2, 0, 3, 3, 0, 2, 2, 2, 2, 0, 3, 3, 0, 2, 2, 1, 1, 0, 2, 2, 0, 1, 1, 1, 1, 0, 2, 2, 0, 1, 1]
s1 = input()
s2 = input()
s3 = input()
s4 = input()
s5 = input()
s6 = input()
f = -1
ed = -1
s = s1 + s2 + s3 + s4 + s5 + s6
for i in range(48):
	if s[i] != '*' and s[i] != '-':
		if int(mas[i]) > ed:
			ed = int(mas[i])
			f = i
s = list(s)
s[f] = 'P'
s = ''.join(s)
for i in range(6):
	print(s[i * 8:i * 8 + 8])


a = []
b = []
b.append(3)
b.append(3)
b.append(0)
b.append(4)
b.append(4)
b.append(0)
b.append(3)
b.append(3)
a.append(b)
b = []
b.append(3)
b.append(3)
b.append(0)
b.append(4)
b.append(4)
b.append(0)
b.append(3)
b.append(3)
a.append(b)
b = []
b.append(2)
b.append(2)
b.append(0)
b.append(3)
b.append(3)
b.append(0)
b.append(2)
b.append(2)
a.append(b)
b = []
b.append(2)
b.append(2)
b.append(0)
b.append(3)
b.append(3)
b.append(0)
b.append(2)
b.append(2)
a.append(b)
b = []
b.append(1)
b.append(1)
b.append(0)
b.append(2)
b.append(2)
b.append(0)
b.append(1)
b.append(1)
a.append(b)
b = []
b.append(1)
b.append(1)
b.append(0)
b.append(2)
b.append(2)
b.append(0)
b.append(1)
b.append(1)
a.append(b)
max = 0
a1 = []
pos1 = 0
pos2 = 0
for i in range(6):
	str = input()
	for i1 in range(8):
		if str[i1] == '.' and a[i][i1] > max:
			max = a[i][i1]
			pos1 = i
			pos2 = i1
	a1.append(str)
for i in range(6):
	for i1 in range(8):
		if i == pos1 and i1 == pos2:
			print('P', end='')
		else:
			print(a1[i][i1], end='')
	print()


room = []
values = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
for i in range(6):
	room.append(input())
(px, py) = (-1, -1)
best = -1
for i in range(6):
	for j in range(8):
		if room[i][j] == '.' and best < values[i][j]:
			(px, py) = (i, j)
			best = values[i][j]
ans = []
for i in range(6):
	if px != i:
		ans.append(room[i])
	else:
		ans.append(room[i][:py] + 'P' + room[i][py + 1:])
for i in range(6):
	print(ans[i])


def f(x, y):
	return 3 - y + (x == 1)

def g(y):
	return y // 2
S = list()
ans = 0
for i in range(0, 6):
	s = input()
	for j in range(0, len(s)):
		if s[j] == '.':
			ans = max(ans, f(j // 3, g(i)))
	S.append(s)
flag = True
for i in range(0, 6):
	s = S[i]
	if flag:
		for j in range(0, len(s)):
			if s[j] == '.' and f(j // 3, g(i)) == ans:
				if j == 0:
					s = 'P' + s[1:]
				else:
					s = s[0:j] + 'P' + s[j + 1:]
				flag = False
				break
	print(s)


def print_results(rows):
	for item in rows:
		print(item)

def main():
	rows = []
	for i in range(6):
		rows.append(input())
	new_row = ''
	for (i, row) in enumerate(rows):
		if row[3] == '.':
			rows[i] = row[:3] + 'P' + row[4:]
			print_results(rows)
			return
		elif row[4] == '.':
			rows[i] = row[:4] + 'P' + row[5:]
			print_results(rows)
			return
		if new_row != '':
			rows[i - 1] = new_row
			print_results(rows)
			return
		if row[0] == '.':
			new_row = 'P' + row[1:]
		elif row[1] == '.':
			new_row = row[0] + 'P' + row[2:]
		elif row[6] == '.':
			new_row = row[:6] + 'P' + row[7]
		elif row[7] == '.':
			new_row = row[:7] + 'P'
	rows[5] = new_row
	print_results(rows)
	return
main()


m = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
mx = 0
k = [list(input().replace('-', '')) for i in range(6)]
for y in range(6):
	for x in range(6):
		if k[y][x] == '.':
			if m[y][x] > mx:
				mx = max(m[y][x], mx)
				maxpos = (y, x)
k[maxpos[0]][maxpos[1]] = 'P'
k = [l[:2] + ['-'] + l[2:4] + ['-'] + l[4:] for l in k]
for l in k:
	print(*l, sep='')


ar = [[3, 3, -1, 4, 4, -1, 3, 3], [3, 3, -1, 4, 4, -1, 3, 3], [2, 2, -1, 3, 3, -1, 2, 2], [2, 2, -1, 3, 3, -1, 2, 2], [1, 1, -1, 2, 2, -1, 1, 1], [1, 1, -1, 2, 2, -1, 1, 1]]
std = []

def main():
	mx = -1
	mq = -1
	mi = -1
	for q in range(6):
		s = input()
		std.append(s)
		for i in range(8):
			if s[i] == '.' and ar[q][i] > mx:
				mx = ar[q][i]
				mq = q
				mi = i
	for q in range(6):
		s = ''
		for i in range(8):
			if q == mq and i == mi:
				s += 'P'
			else:
				s += std[q][i]
		print(s)
main()


a = []

def printgrid():
	for i in range(6):
		for j in range(len(a[i])):
			print(a[i][j], end='')
		print()

def solve():
	for i in range(6):
		x = list(input())
		a.append(x)
	for i in [0, 1]:
		for j in [3, 4]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
	for i in [0, 1]:
		for j in [0, 1, 6, 7]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
	for i in [2, 3]:
		for j in [3, 4]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
	for i in [2, 3]:
		for j in [0, 1, 6, 7]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
	for i in [4, 5]:
		for j in [3, 4]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
	for i in [4, 5]:
		for j in [0, 1, 6, 7]:
			if a[i][j] == '.':
				a[i][j] = 'P'
				printgrid()
				return
solve()


a = [[3, 3, 4, 4, 3, 3], [3, 3, 4, 4, 3, 3], [2, 2, 3, 3, 2, 2], [2, 2, 3, 3, 2, 2], [1, 1, 2, 2, 1, 1], [1, 1, 2, 2, 1, 1]]
b = [''.join(input().split('-')) for i in range(6)]
ans = []
for i in range(6):
	for j in range(6):
		if b[i][j] == '.':
			ans.append([a[i][j], i, j])
ans.sort(reverse=True)
for i in range(6):
	for j in range(6):
		if i == ans[0][1] and j == ans[0][2]:
			print('P', end='')
		else:
			print(b[i][j], end='')
		if j == 1 or j == 3:
			print('-', end='')
	print('')


conv_map = [[3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1]]
(res, prev) = (0, None)
a = [list(input()) for _ in range(6)]
for i in range(6):
	for j in range(8):
		if a[i][j] == '.':
			if conv_map[i // 2][j] > res:
				a[i][j] = 'P'
				if prev:
					a[prev[0]][prev[1]] = '.'
				prev = (i, j)
				res = conv_map[i // 2][j]
print('\n'.join((''.join(ai) for ai in a)))


cc = [[3, 3, 0, 4, 4, 0, 3, 3], [3, 3, 0, 4, 4, 0, 3, 3], [2, 2, 0, 3, 3, 0, 2, 2], [2, 2, 0, 3, 3, 0, 2, 2], [1, 1, 0, 2, 2, 0, 1, 1], [1, 1, 0, 2, 2, 0, 1, 1]]
m = 0
mi = -1
mj = -1
ss = []
for i in range(6):
	s = list(input())
	ss.append(s)
	for j in range(8):
		if s[j] == '.':
			if cc[i][j] > m:
				m = cc[i][j]
				mi = i
				mj = j
if mi != -1 and mj != -1:
	ss[mi][mj] = 'P'
for i in range(6):
	print(''.join(ss[i]))