#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

enum PLAYER{
	Enemy,
	Wizzard,
	Did,
	Passed,
};

enum DIST{
	Migi,
	Hidari,
	Ue,
	Shita,
	Migiue,
	Hidarishita,
	Migishita,
	Hidariue,
};

struct Info{
	int row,col,num;
	bool checkTable[8];
};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= 7 && col >= 0 && col <= 7)return true;
	else{
		return false;
	}
}

int main(){
	char table[8][9],mine,yours;
	Info work[64];
	int work_index;
	bool FLG;

	for(int i = 0; i < 8; i++){
		scanf("%s",table[i]);
	}

	PLAYER player = Enemy,state = Did;

	while(true){

		if(player == Enemy){
			mine = 'o';
			yours = 'x';
		}else{
			mine = 'x';
			yours = 'o';
		}

		for(int i = 0; i < 64; i++){
			work[i].num = 0;
			for(int k = 0; k < 8; k++){
				work[i].checkTable[k] = false;
			}
		}

		work_index = 0;

		for(int i = 0; i < 8; i++){
			for(int k = 0,p; k < 8; k++){

				if(table[i][k] == '.' && rangeCheck(i,k+1) == true && table[i][k+1] == yours){
					for(p = 0; rangeCheck(i,k+1+p) == true && table[i][k+1+p] == yours;p++);
					if(rangeCheck(i,k+1+p) == true &&table[i][k+1+p] == mine){
						work[work_index].row = i;
						work[work_index].col = k;
						work[work_index].num += p;
						work[work_index].checkTable[Migi] = true;
						work_index++;
					}
				}


				if(table[i][k] == '.' && rangeCheck(i,k-1) == true && table[i][k-1] == yours){
					for(p = 0; rangeCheck(i,k-1-p) == true && table[i][k-1-p] == yours;p++);
					if(rangeCheck(i,k-1-p) == true && table[i][k-1-p] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Hidari] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Hidari] = true;
							work_index++;
						}
					}
				}


				if(table[i][k] == '.' && rangeCheck(i-1,k) == true && table[i-1][k] == yours){
					for(p = 0; rangeCheck(i-1-p,k) == true && table[i-1-p][k] == yours;p++);
					if(rangeCheck(i-1-p,k) == true && table[i-1-p][k] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Ue] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Ue] = true;
							work_index++;
						}
					}
				}


				if(table[i][k] == '.' && rangeCheck(i+1,k) == true && table[i+1][k] == yours){
					for(p = 0; rangeCheck(i+1+p,k) == true && table[i+1+p][k] == yours;p++);
					if(rangeCheck(i+1+p,k) == true && table[i+1+p][k] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Shita] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Shita] = true;
							work_index++;
						}
					}
				}

				if(table[i][k] == '.' && rangeCheck(i+1,k+1) == true && table[i+1][k+1] == yours){
					for(p = 0; rangeCheck(i+1+p,k+1+p) == true && table[i+1+p][k+1+p] == yours;p++);
					if(rangeCheck(i+1+p,k+1+p) == true && table[i+1+p][k+1+p] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Migishita] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Migishita] = true;
							work_index++;
						}
					}
				}

				if(table[i][k] == '.' && rangeCheck(i-1,k-1) == true && table[i-1][k-1] == yours){
					for(p = 0; rangeCheck(i-1-p,k-1-p) == true && table[i-1-p][k-1-p] == yours;p++);
					if(rangeCheck(i-1-p,k-1-p) == true && table[i-1-p][k-1-p] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Hidariue] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Hidariue] = true;
							work_index++;
						}
					}
				}

				if(table[i][k] == '.' && rangeCheck(i-1,k+1) == true && table[i-1][k+1] == yours){
					for(p = 0; rangeCheck(i-1-p,k+1+p) == true && table[i-1-p][k+1+p] == yours;p++);
					if(rangeCheck(i-1-p,k+1+p) == true && table[i-1-p][k+1+p] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Migiue] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Migiue] = true;
							work_index++;
						}
					}
				}

				if(table[i][k] == '.' && rangeCheck(i+1,k-1) == true && table[i+1][k-1] == yours){
					for(p = 0; rangeCheck(i+1+p,k-1-p) == true && table[i+1+p][k-1-p] == yours;p++);
					if(rangeCheck(i+1+p,k-1-p) == true && table[i+1+p][k-1-p] == mine){

						FLG = false;
						for(int a = 0; a < work_index;a++){
							if(work[a].row == i && work[a].col == k){
								FLG = true;
								work[a].num += p;
								work[a].checkTable[Hidarishita] = true;
								break;
							}
						}
						if(!FLG){
							work[work_index].row = i;
							work[work_index].col = k;
							work[work_index].num += p;
							work[work_index].checkTable[Hidarishita] = true;
							work_index++;
						}
					}
				}

			}
		}

		if(work_index == 0){
			if(state == Did){
				state = Passed;
			}else{
				break;
			}
		}else{
			state = Did;

			if(player == Enemy){
				for(int a = 1; a <= work_index-1; a++){
					for(int b = work_index-1; b >=a; b--){
						if((work[b].num > work[b-1].num) || (work[b].num == work[b-1].num && work[b].row < work[b-1].row) ||
								 (work[b].num == work[b-1].num && work[b].row == work[b-1].row && work[b].col < work[b-1].col)){
							swap(work[b],work[b-1]);
						}
					}
				}

			}else{
				for(int a = 1; a <= work_index-1; a++){
					for(int b = work_index-1; b >=a; b--){
						if((work[b].num > work[b-1].num) || (work[b].num == work[b-1].num && work[b].row > work[b-1].row) ||
								 (work[b].num == work[b-1].num && work[b].row == work[b-1].row && work[b].col > work[b-1].col)){
							swap(work[b],work[b-1]);
						}
					}
				}
			}


			table[work[0].row][work[0].col] = mine;

			if(work[0].checkTable[Migi] == true){
				for(int c = work[0].col+1;table[work[0].row][c] == yours; c++){
					table[work[0].row][c] = mine;
				}
			}

			if(work[0].checkTable[Hidari] == true){
				for(int c = work[0].col-1;table[work[0].row][c] == yours; c--){
					table[work[0].row][c] = mine;
				}
			}

			if(work[0].checkTable[Ue] == true){
				for(int c = work[0].row-1;table[c][work[0].col] == yours; c--){
					table[c][work[0].col] = mine;
				}
			}

			if(work[0].checkTable[Shita] == true){
				for(int c = work[0].row+1;table[c][work[0].col] == yours; c++){
					table[c][work[0].col] = mine;
				}
			}

			if(work[0].checkTable[Migishita] == true){
				for(int c = 1;table[work[0].row+c][work[0].col+c] == yours;c++){
					table[work[0].row+c][work[0].col+c] = mine;
				}
			}

			if(work[0].checkTable[Hidariue] == true){
				for(int c = 1;table[work[0].row-c][work[0].col-c] == yours;c++){
					table[work[0].row-c][work[0].col-c] = mine;
				}
			}

			if(work[0].checkTable[Migiue] == true){
				for(int c = 1;table[work[0].row-c][work[0].col+c] == yours;c++){
					table[work[0].row-c][work[0].col+c] = mine;
				}
			}

			if(work[0].checkTable[Hidarishita] == true){
				for(int c = 1;table[work[0].row+c][work[0].col-c] == yours;c++){
					table[work[0].row+c][work[0].col-c] = mine;
				}
			}
		}

		if(player == Enemy){
			player = Wizzard;
		}else{
			player = Enemy;
		}

	}

	for(int i = 0; i < 8; i++){
		for(int k = 0; k < 8; k++)printf("%c",table[i][k]);
		printf("\n");
	}

}

Measured memory_bytes: 2692