#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
/*}}}*/
vector<string> s(8);

void check(){
    cout << "check" << endl;
    rep(i,8) cout << s[i] << endl;
}

// turn = 0 then me = o
int count(int x,int y,char me){
    int ret = 0;
    for(int dx=-1;dx<2;dx++) for(int dy=-1;dy<2;dy++){
        if(dx==0 and dy==0) continue;

        //cout << dx << " " << dy << endl;
        for(int i=1;i<8;i++){
            int nx = x + dx*i;
            int ny = y + dy*i;
            //cout << "next : " << nx << " " << ny << endl;
            if(nx<0 or ny<0 or nx>=8 or ny>=8) break;
            if(s[nx][ny]=='.') break;
            if(s[nx][ny]==me){
                //cout << "hit : " << nx << " " << ny << " " << i-1 << endl;
                ret += i-1;
                break;
            }
        }
    }
    return ret;
}

bool f(int turn){
    //check();
    int cnt = 0;
    int cx,cy;
    if(turn==0){    // mami
        rep(i,8) rep(j,8) if(s[i][j]=='.'){
            int t = count(i,j,'o');
            if(cnt < t){
                cnt = t;
                cx=i;
                cy=j;
            }
        }
        if(cnt==0) return false;
        int x = cx;
        int y = cy;
        for(int dx=-1;dx<2;dx++) for(int dy=-1;dy<2;dy++){
            if(dx==0 and dy==0) continue;

            for(int i=1;i<8;i++){
                int nx = x + dx*i;
                int ny = y + dy*i;
                if(nx<0 or ny<0 or nx>=8 or ny>=8) break;
                if(s[nx][ny]=='.') break;
                if(s[nx][ny]=='o'){
                    for(int j=1;j<i;j++){
                        s[x+dx*j][y+dy*j]='o';
                    }
                    break;
                }
            }
        }
        s[cx][cy] = 'o';
    }else{
        rep(i,8) rep(j,8) if(s[i][j]=='.'){
            int t = count(i,j,'x');
            if(cnt <= t){
                cnt = t;
                cx=i;
                cy=j;
            }
        }
        if(cnt==0) return false;
        int x = cx;
        int y = cy;
        for(int dx=-1;dx<2;dx++) for(int dy=-1;dy<2;dy++){
            if(dx==0 and dy==0) continue;

            for(int i=1;i<8;i++){
                int nx = x + dx*i;
                int ny = y + dy*i;
                if(nx<0 or ny<0 or nx>=8 or ny>=8) break;
                if(s[nx][ny]=='.') break;
                if(s[nx][ny]=='x'){
                    for(int j=1;j<i;j++){
                        s[x+dx*j][y+dy*j]='x';
                    }
                    break;
                }
            }
        }
        s[cx][cy]='x';
    }
    return true;
}


int main(){
    rep(i,8) cin >> s[i];
    int turn = 0;   // 0 :mami , 1:majo
    while(1){
        //check();
        auto t = s;
        //bool y = f(turn);
        //if(!y) break;
        f(0);
        f(1);
        turn++;
        turn%=2;
        if(t==s) break;
    }

    //s[0] = "....o...";
    //s[1] = "....o...";
    //s[2] = "....o...";
    //s[3] = "...oo...";
    //s[4] = "...oxxxx";
    //s[5] = "..o.....";
    //s[6] = ".o......";
    //s[7] = "o.......";

    //int p = count(4,2,'x');
    //cout << p << endl;
    //cout << "answer: " << endl;
    rep(i,8) cout << s[i] << endl;
}

Measured memory_bytes: 3236