#include <iostream>
#include <string>

#define BLACK 1
#define WHITE 10
#define NORMAL 0

#define DEBUG 0

using namespace std;

class Point{

public:
	int x, y;

};

int abs(int a){
	if (a < 0){
		return a*-1;
	}
	else{
		return a;
	}
}

int max(int a, int b){
	return a >= b ? a : b;
}

int isIn(int x, int y){
	if (x < 0 || 9<=x || y < 0 || 9<=y){
		return 0;
	}
	else{
		return 1;
	}
}

int isEqualColor(int x, int y, int **data,int color){
	if (data[y][x] == color){
		return 1;
	}
	else{
		return 0;
	}
}

int changeColorNum(Point start, Point end){
	return max(abs(start.x - end.x)-1, abs(start.y - end.y)-1);
}

Point searchNextCookie(Point start, int **data, int direction,int color){

	int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
	int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };

	Point p;
	p.x = -1;
	p.y = -1;

	for (int i = 1;; i++){
		int nowX = start.x + dx[direction] * i;
		int nowY = start.y + dy[direction] * i;
		if (isIn(nowX, nowY)==0){
			break;
		}
		if (isEqualColor(nowX, nowY, data, NORMAL)){
			break;
		}

		if (isEqualColor(nowX, nowY, data, color)){
			p.x = nowX;
			p.y = nowY;
			break;
		}
	}
	return p;
}

void changeData(Point point, int **data,int turn){

	data[point.y][point.x] = turn;
	
	int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
	int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };

	for (int i = 0; i < 8; i++){
		if (searchNextCookie(point, data, i, turn).x != -1){

			for (int j = 1;; j++){
				Point next;
				next.x = point.x + dx[i] * j;
				next.y = point.y + dy[i] * j;
				if (isEqualColor(next.x, next.y, data, turn)){
					break;
				}
				data[next.y][next.x] = turn;
			}
		}
	}
}

void show(int **data){
	for (int i = 1; i < 9; i++){
		for (int j = 1; j < 9; j++){
			if (data[i][j] == BLACK){
				cout << 'o';
			}
			else if (data[i][j] == WHITE){
				cout << 'x';
			}
			else{
				cout << '.';
			}
		}
		cout << endl;
	}
	if (DEBUG)cout << endl;
}

int changeTurn(int turn){
	if (turn == BLACK){
		return WHITE;
	}
	else{
		return BLACK;
	}
}

int main(){

	int **data = new int *[10];
	for (int i = 0; i < 10; i++){
		data[i] = new int[10];
	}
	char tmp;

	for (int i = 1; i < 9; i++){
		for (int j = 1; j < 9; j++){
			cin >> tmp;
			if (tmp == 'o'){
				data[i][j] = BLACK;
			}
			else if (tmp == 'x'){
				data[i][j] = WHITE;
			}
			else{
				data[i][j] = NORMAL;
			}
		}
	}

	if (DEBUG)show(data);

	int turn = WHITE;
	int breakCnt = 0;
	while (1){
		turn = changeTurn(turn);
		if (breakCnt >= 2){
			break;
		}


		int changeNum = 0;
		Point maxP;
		maxP.x = -1;
		maxP.y = -1;

		//????????´???????±?????????????
		for (int i = 1; i < 9; i++){
			for (int j = 1; j < 9; j++){
				if (isEqualColor(j, i, data, NORMAL)){
					int nowChangeNum = 0;
					Point start;
					start.x = j, start.y = i;
					for (int k = 0; k < 8; k++){
						Point next = searchNextCookie(start, data, k, turn);
						if (next.x == -1)continue;

						nowChangeNum += changeColorNum(start, next);
					}

					if (turn == BLACK){
						if (changeNum < nowChangeNum && nowChangeNum != 0){
							maxP.x = start.x;
							maxP.y = start.y;
							changeNum = nowChangeNum;
						}
					}
					else{
						if (changeNum <= nowChangeNum && nowChangeNum != 0){
							maxP.x = start.x;
							maxP.y = start.y;
							changeNum = nowChangeNum;
						}
					}
				}
			}
		}
		if (maxP.x == -1){
			breakCnt++;
			continue;
		}
		else{
			breakCnt = 0;
		}


		changeData(maxP, data, turn);

		if (DEBUG)show(data);
	}

	show(data);


}

Measured memory_bytes: 3116