#include <iostream>
#include <vector>
#define N 10
using namespace std;
int Check(string);
int Cnt(string,int,int,int,int);
void Reverse(int,int,string,vector<int>);
string in[N];
int main(){
  int r,end,i,j;
  string who="o";
  for(i=0;i<N;i++) in[0]+='X',in[N-1]+='X';
  for(i=1;i<N-1;i++) cin >> in[i],in[i]='X'+in[i]+'X';
  end=0;
  while(1){
    r=Check(who);
    if(r==0) end++;
    else end=0;
    if(end==2) break;
    who=="o" ? who="x" : who="o";
  }
  for(i=1;i<=8;i++){
    for(j=1;j<=8;j++){
      cout << in[i][j];
    }
    cout << endl;
  }
  return 0;
}
int Check(string who){
  int cnt,r,max=0,i,j;
  char ox;
  pair<int,int> i_j;
  vector<int> m,t;
  if(who=="o") ox='x';
  else ox='o';
  if(who=="o"){
    for(i=1;i<N-1;i++){
      for(j=1;j<N-1;j++){
	if(in[i][j]=='.'){
	  for(int k=0;k<8;k++) t.push_back(0);
	  cnt=0;
	  if(in[i][j-1]==ox){
	    r=Cnt(who,i,j-1,0,-1);
	    cnt+=r;
	    t[0]=r;
	  }
	  if(in[i-1][j-1]==ox){
	    r=Cnt(who,i-1,j-1,-1,-1);
	    cnt+=r;
	    t[1]=r;
	  }
	  if(in[i-1][j]==ox){
	    r=Cnt(who,i-1,j,-1,0);
	    cnt+=r;
	    t[2]=r;
	  }
	  if(in[i-1][j+1]==ox){
	    r=Cnt(who,i-1,j+1,-1,1);
	    cnt+=r;
	    t[3]=r;
	  }
	  if(in[i][j+1]==ox){
	    r=Cnt(who,i,j+1,0,1);
	    cnt+=r;
	    t[4]=r;
	  }
	  if(in[i+1][j+1]==ox){
	    r=Cnt(who,i+1,j+1,1,1);
	    cnt+=r;
	    t[5]=r;
	  }
	  if(in[i+1][j]==ox){
	    r=Cnt(who,i+1,j,1,0);
	    cnt+=r;
	    t[6]=r;
	  }
	  if(in[i+1][j-1]==ox){
	    r=Cnt(who,i+1,j-1,1,-1);
	    cnt+=r;
	    t[7]=r;
	  }
	  if(max<cnt){
	    max=cnt;
	    i_j=make_pair(i,j);
	    m=t;	  
	  }
	  t.clear();
	}
      }
    }
  }else{
    for(i=N-2;i>=1;i--){
      for(j=N-2;j>=1;j--){
	if(in[i][j]=='.'){
	  for(int k=0;k<8;k++) t.push_back(0);
	  cnt=0;
	  if(in[i][j-1]==ox){
	    r=Cnt(who,i,j-1,0,-1);
	    cnt+=r;
	    t[0]=r;
	  }
	  if(in[i-1][j-1]==ox){
	    r=Cnt(who,i-1,j-1,-1,-1);
	    cnt+=r;
	    t[1]=r;
	  }
	  if(in[i-1][j]==ox){
	    r=Cnt(who,i-1,j,-1,0);
	    cnt+=r;
	    t[2]=r;
	  }
	  if(in[i-1][j+1]==ox){
	    r=Cnt(who,i-1,j+1,-1,1);
	    cnt+=r;
	    t[3]=r;
	  }
	  if(in[i][j+1]==ox){
	    r=Cnt(who,i,j+1,0,1);
	    cnt+=r;
	    t[4]=r;
	  }
	  if(in[i+1][j+1]==ox){
	    r=Cnt(who,i+1,j+1,1,1);
	    cnt+=r;
	    t[5]=r;
	  }
	  if(in[i+1][j]==ox){
	    r=Cnt(who,i+1,j,1,0);
	    cnt+=r;
	    t[6]=r;
	  }
	  if(in[i+1][j-1]==ox){
	    r=Cnt(who,i+1,j-1,1,-1);
	    cnt+=r;
	    t[7]=r;
	  }
	  if(max<cnt){
	    max=cnt;
	    i_j=make_pair(i,j);
	    m=t;	  
	  }
	  t.clear();
	}
      }
    }
  }
  if(max==0) return 0;
  Reverse(i_j.first,i_j.second,who,m);
  return 1;
}
int Cnt(string who,int y,int x,int py,int px){
  int cnt=1;
  char ox,oxr;
  if(who=="o") ox='x',oxr='o';
  else ox='o',oxr='x';
  while(1){
    y+=py;
    x+=px;
    if(in[y][x]==oxr) break;
    else if(in[y][x]==ox) cnt++;
    else{
      cnt=0;
      break;
    }
  }
  return cnt;
}
void Reverse(int y,int x,string who,vector<int> V){
  int i,cpy=y,cpx=x;
  char ox,oxr;
  int py[8]={0,-1,-1,-1,0,1,1,1},px[8]={-1,-1,0,1,1,1,0,-1};
  if(who=="o") ox='x',oxr='o';
  else ox='o',oxr='x';
  in[cpy][cpx]=oxr;
  for(i=0;i<V.size();i++){
    cpy=y,cpx=x;
    if(V[i]!=0){
      if(i==0){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==1){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==2){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==3){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==4){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==5){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==6){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
      else if(i==7){
	while(V[i]){
	  cpy+=py[i];
	  cpx+=px[i];
	  in[cpy][cpx]=oxr;
	  V[i]--;
	}
      }
    }
  }
}

Measured memory_bytes: 1220