#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

bool isIn(int x, int y){
    return 0 <= x && x < 8 && 0 <= y && y < 8;
}

int main(){
    string field[8];
    int cost[8][8];
    for(int i=0; i< 8; i++) cin >> field[i];

    bool pass = false;
    for(int q=0; ; q++){
        for(int i=0; i< 8; i++)for(int j=0; j< 8; j++) cost[i][j] = 0;
        string s = "ox";

        int maxReverse = 0;
        for(int i=0; i< 8; i++){
            for(int j=0; j< 8; j++){
                if(field[i][j] == '.'){
                    int count = 0;
                    for(int dx = -1; dx <= 1; dx++){
                        for(int dy = -1; dy <= 1; dy++){
                            if(dx == 0 && dy == 0) continue;
                            if(isIn(i+dx, j+dy) && field[i+dx][j+dy] == s[(q+1)%2]){
                                int c = 0;
                                for(c=1; isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] == s[(q+1)%2]; c++);

                                if(isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] != '.') count += c-1;
                            }
                        }
                    }
                    maxReverse = max(maxReverse, count);
                    cost[i][j] = count;
                }
            }
        }
        if(maxReverse == 0 && pass) break;
        else if(maxReverse != 0) pass = false;
        else if(maxReverse == 0){pass = true; continue;}

        if(q%2 == 0){
            for(int i=0; i< 8; i++){
                for(int j=0; j< 8; j++){
                    if(cost[i][j] == maxReverse){
                        field[i][j] = s[q%2];
                        for(int dx = -1; dx <= 1; dx++){
                            for(int dy = -1; dy <= 1; dy++){
                                if(dx == 0 && dy == 0) continue;
                                if(isIn(i+dx, j+dy) && field[i+dx][j+dy] == s[(q+1)%2]){
                                    bool is = true;
                                    int c = 0;
                                    for(c=1; isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] == s[(q+1)%2]; c++);
                                    if(isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] != '.') for(int p=0; p < c; p++) field[i+dx*p][j+dy*p] = s[q%2];
                                }
                            }
                        }
                        i = 10; j = 10;
                    }
                }
            }
        }
        else {
            for(int i=7; 0 <= i; i--){
                for(int j=7; 0 <= j; j--){
                    if(cost[i][j] == maxReverse){
                        field[i][j] = s[q%2];
                        for(int dx = -1; dx <= 1; dx++){
                            for(int dy = -1; dy <= 1; dy++){
                                if(dx == 0 && dy == 0) continue;
                                if(isIn(i+dx, j+dy) && field[i+dx][j+dy] == s[(q+1)%2]){
                                    bool is = true;
                                    int c = 0;
                                    for(c=1; isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] == s[(q+1)%2]; c++);
                                    if(isIn(i+dx*c, j+dy*c) && field[i+dx*c][j+dy*c] != '.') for(int p=0; p < c; p++) field[i+dx*p][j+dy*p] = s[q%2];
                                }
                            }
                        }
                        i = -1; j = -1;
                    }
                }
            }
        }
    }
    for(int i=0; i< 8; i++) cout << field[i] << endl;
}

Measured memory_bytes: 1192