#include<iostream>
#include<string>
using namespace std;

string table[8];
int dx[] = {0,1,1,1,0,-1,-1,-1};
int dy[] = {-1,-1,0,1,1,1,0,-1};
bool isInRange(int nx,int ny)
{
	if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8)return false;
	return true;
}

int isPut(int x,int y,char putCookie)
{
	int maxReverse = 0;
	for (int i = 0; i < 8; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		
		int count = 0;
		while (isInRange(nx, ny) && table[ny][nx] != putCookie && table[ny][nx] != '.')
		{
			if (putCookie == table[ny][nx])break;
			count++;
			nx += dx[i];
			ny += dy[i];
		}

		if (isInRange(nx,ny) && table[ny][nx] == putCookie)
		{
			maxReverse += count;
		}
	}
	return maxReverse;
}
void reversing(int px, int py,char putCookie)
{
	//?????????????????????????????????
	table[py][px] = putCookie;

	char targetCookie;
	if (putCookie == 'o')targetCookie = 'x';
	else targetCookie = 'o';

	for (int i = 0; i < 8; i++)
	{
		int ny = py + dy[i];
		int nx = px + dx[i];
		bool isPut = false;

		int canReverseCount = 0;
		while (isInRange(nx,ny) && table[ny][nx] != '.')
		{
			if (putCookie == table[ny][nx])
			{
				isPut = true;
				break;
			}
			canReverseCount++;
			ny += dy[i];
			nx += dx[i];
		}

		if (isPut)
		{
			int nextY = py + dy[i];
			int nextX = px + dx[i];
			for (int j = 0; j < canReverseCount; j++)
			{
				table[nextY][nextX] = putCookie;
				nextY = nextY + dy[i];
				nextX= nextX + dx[i];
			}
		}
	}
}
//???????????´???true?????????
bool searchPutPos(char putCookie,int turn)
{
	int maxReverse = 0;
	int putX = 0;
	int putY = 0;
	if (turn % 2 == 0)//??´??????????????????
	{
		for (int i = 0; i < 8; i++)
		{
			for (int j = 0; j < 8; j++)
			{
				if (table[i][j] != '.')continue;
				//???????????????????????????????????´??????
				//???????????¬????????????????????????????????¢??????????????¨?????§????????°???????????????
				int reverseNumber = isPut(j, i, putCookie);
				if (reverseNumber == 0)continue;
				if (maxReverse < reverseNumber)
				{
					maxReverse = reverseNumber;
					putX = j;
					putY = i;
				}
			}
		}
	}
	else//????????????????\?????????????
	{
		for (int i = 7; i >= 0; i--)
		{
			for (int j = 7; j >= 0; j--)
			{
				if (table[i][j] != '.')continue;
				int reverseNumber = isPut(j, i, putCookie);
				if (reverseNumber == 0)continue;
				if (maxReverse < reverseNumber)
				{
					maxReverse = reverseNumber;
					putX = j;
					putY = i;
				}
			}
		}
	}
	//?????¢??????????????¨?????§???????????´???
	if (maxReverse == 0)return false;

	//?????¢??????
	reversing(putX,putY,putCookie);

	//cout << putX << " "<<putY << endl;
	return true;
}
int main()
{
	for (int i = 0; i < 8; i++)
	{
		cin >> table[i];
	}
	bool pfind = true;
	for (int turn = 0;;turn++)
	{
		char putCookie = '-';//?????????????????????????????\??????
		if (turn % 2 == 1)//????????????????\?????????????
		{
			putCookie = 'x';//?????????????????????
		}
		else//??´??????????????????
		{
			putCookie = 'o';//?????§?????¬??????????????????
		}
		//??????????????????????????´?????????????????£???????????????bool?????????
		bool find = searchPutPos(putCookie, turn);

		if (!find && !pfind)//????????????????????¬????????????????????????????????£?????????????????????
		{
			break;
		}
		pfind = find;
		//cout << turn << endl;
	}

	for (int i = 0; i < 8; i++)
	{
		cout << table[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1184