#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

vector<string> a(9);
int dy[8] = {-1,-1, 0, 1, 1, 1, 0,-1};
int dx[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
char c[2] = {'x', 'o'};

// x first o second

bool q(int y, int x) {
    if (y >= 0 && y < 8 && x >= 0 && x < 8) return true;
    else return false;
}

int check(int y, int x, int type) {
    int ret = 0;
    for (int k = 0; k < 8; k++) {
        int ty = y+dy[k], tx = x+dx[k];
        if (q(ty, tx) && a[ty][tx] == c[type]) {
            int cnt = 1;
            ty += dy[k], tx += dx[k];
            while (1) {
                if (q(ty, tx) && a[ty][tx] == c[type]) {
                    cnt++;
                    ty += dy[k]; tx += dx[k];
                }
                else break;
            }
            if (q(ty, tx) && a[ty][tx] == c[(type+1)%2]) {
                ret += cnt;
            }
        }
    }
    return ret;
}

void draw(int y, int x, int type) {
    //cerr << "y=" << y << " x=" << x << " type=" << type << endl;
    a[y][x] = c[(type+1)%2];
    for (int k = 0; k < 8; k++) {
        int ty = y+dy[k], tx = x+dx[k];
        if (q(ty, tx) && a[ty][tx] == c[type]) {
            ty += dy[k], tx += dx[k];
            while (1) {
                if (q(ty, tx) && a[ty][tx] == c[type]) {
                    ty += dy[k]; tx += dx[k];
                }
                else break;
            }
            if (q(ty, tx) && a[ty][tx] == c[(type+1)%2]) {
                while (ty != y || tx != x) {
                    ty -= dy[k]; tx -= dx[k];
                    a[ty][tx] = c[(type+1)%2];
                    //cerr << " draw = " << ty << " " << tx << endl;
                }
            }
        }
    }
    /*
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cerr << a[i][j] << " ";
        }
        cerr << endl;
    }
    */
}

int main(void){
    for (int i = 0; i < 8; i++) cin >> a[i];
    
    bool f[2];
    while (1) {
        f[0] = false; f[1] = false;
        for (int k = 0; k < 2; k++) {
            int p = 0;
            int bx, by;
            for (int i = 0; i < 8; i++) {
                for (int j = 0; j < 8; j++) {
                    if (a[i][j] == 'o' || a[i][j] == 'x') continue;
                    int tp = check(i,j,k);
                    if (tp) {
                        //cerr << "i=" << i << " j= " << j << endl;
                        f[k] = true;
                        if (tp > p) {
                            p = tp; by = i; bx = j;
                        }
                        else if (tp == p) {
                            if (k == 0) {
                                if (i < by) {
                                    by = i; bx = j;
                                }
                                else if (i == by && j < bx) {
                                    by = i; bx = j;
                                }
                            }
                            else if (k == 1) {
                                if (i > by) {
                                    by = i; bx = j;
                                }
                                else if (i == by && j > bx) {
                                    by = i; bx = j;
                                }
                            }
                        }
                    }
                }
            }
            //cerr << "P=" << p << " ";
            if (f[k] == true) draw(by, bx, k);
        }
        if (f[0] == false && f[1] == false) break;
    }
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3204