#include<stdio.h>
#include<iostream>
#include<utility>
#include<string.h>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int search(char *ban,int y,int x,int dis,int jo)
{
    if(y<0||y>8)return 0;
    if(x<0||x>8)return 0;
    int dx[8]={0,1,1,1,0,-1,-1,-1};
    int dy[8]={1,1,0,-1,-1,-1,0,1};
    if((y+dy[dis]>=8 || y+dy[dis]<0))return 0;
    if((x+dx[dis]>=8 || x+dx[dis]<0))return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])==*(ban+8*y+x))return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])=='.')return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])!=*(ban+8*y+x))
    {
        int a=search(ban,y+dy[dis],x+dx[dis],dis,1);
        if(a>=1)return a;
        else return 0;
    }
    else if(jo==1)
    {
        if(*(ban+8*(y+dy[dis])+x+dx[dis])==*(ban+8*y+x))
        {
            int a=search(ban,y+dy[dis],x+dx[dis],dis,1);
            if(a>=1)return a+1;
            else return 0;
        }
        else if(*(ban+8*(y+dy[dis])+x+dx[dis])=='.')return 0;
        else return 1;
    }
    return 0;
}

void printban(char *ban)
{
    REP(i,8)
    {
        REP(j,8)printf("%c",*(ban+8*i+j));
        printf("\n");
    }
    return;
}

int re(char *ban, int y,int x , int dis ,int jo)
{
    if(y<0||y>8)return 0;
    if(x<0||x>8)return 0;
    int dx[8]={0,1,1,1,0,-1,-1,-1};
    int dy[8]={1,1,0,-1,-1,-1,0,1};
    if((y+dy[dis]>=8 || y+dy[dis]<0))return 0;
    if((x+dx[dis]>=8 || x+dx[dis]<0))return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])==*(ban+8*y+x))return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])=='.')return 0;
    else if(jo==0&&*(ban+8*(y+dy[dis])+x+dx[dis])!=*(ban+8*y+x))
    {
        if(re(ban,y+dy[dis],x+dx[dis],dis,1)==1)return 1;
    }
    else if(jo==1)
    {
        if(*(ban+8*(y+dy[dis])+x+dx[dis])==*(ban+8*y+x))
        {
            if(re(ban,y+dy[dis],x+dx[dis],dis,1)==1)
            {
                *(ban+8*y+x)='o'+'x'-*(ban+8*y+x);
                return 1;
            }
            else return 0;
        }
        else if(*(ban+8*(y+dy[dis])+x+dx[dis])=='.')return 0;
        else
        {
            *(ban+8*y+x)='o'+'x'-*(ban+8*y+x);
            return 1;
        }
    }
    return 0;
}

int main()
{
    char ban[64]={};
    REP(i,8)
    {
        REP(j,8)scanf("%c",&ban[i*8+j]);
        scanf("\n");
    }
    int none=0;
    int now=0;
    int rexo[64]={};
    int max;
    int maxban;
    while(1==1)
    {
        REP(i,64)rexo[i]=0;
        max=0;
        maxban=-1;
        if(now==0)
        {
            REP(i,64)
            {
                if(ban[i]=='.')
                {
                    ban[i]='o';
                    REP(k,8)rexo[i]+=search(&ban[0],i/8,i%8,k,0);
                    ban[i]='.';
                }
            }
            REP(i,64)if(max<rexo[i])
            {
                max=rexo[i];
                maxban=i;
            }
            ban[maxban]='o';
            REP(k,8)re(ban,maxban/8,maxban%8,k,0);
            if(max==0)none++;
            else none=0;
            if(none==2)break;
        }
        else if(now==1)
        {
            for(int i=63;i>=0;i--)
            {
                if(ban[i]=='.')
                {
                    ban[i]='x';
                    REP(k,8)rexo[i]+=search(&ban[0],i/8,i%8,k,0);
                    ban[i]='.';
                }
            }
            for(int i=63;i>=0;i--)if(max<rexo[i])
            {
                max=rexo[i];
                maxban=i;
            }
            ban[maxban]='x';
            REP(k,8)re(ban,maxban/8,maxban%8,k,0);
            if(max==0)none++;
            else none=0;
            if(none==2)break;
        }
        now=1-now;
        //REP(i,64)printf("%d",rexo[i]);
        //printf("\n");
        //printban(ban);
        //printf("############\n");
    }
    printban(ban);
}


Measured memory_bytes: 3172