#include <bits/stdc++.h>
using namespace std;

using reversePiece = pair<pair<int, int>, vector<pair<int, int>>>;

// 8x8 + 場外
vector<vector<char>> board(10, vector<char>(10, '#'));

void show() {
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) {
            cout << board[i][j];
        }
        cout << endl;
    }
}

vector<reversePiece> canMove(char myPiece) {
    char enemiesPiece = myPiece == 'o' ? 'x' : 'o';
    vector<reversePiece> moveList;
    vector<int> dx = {-1, -1, 0, 1, 1, 1, 0, -1};
    vector<int> dy = {0, 1, 1, 1, 0, -1, -1, -1};
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) {
            vector<pair<int, int>> cnt;
            if (board[i][j] != '.') continue;
            for (int k = 0; k < 8; k++) {
                int y = i;
                int x = j;
                vector<pair<int, int>> oneWayCnt;
                // int oneWayCnt = 0;
                while (true) {
                    y += dy[k];
                    x += dx[k];
                    if (board[y][x] == enemiesPiece)
                        oneWayCnt.push_back(make_pair(y, x));
                    else if (board[y][x] == myPiece && oneWayCnt.size()) {
                        for (auto i : oneWayCnt) {
                            cnt.push_back(i);
                        }
                        break;
                    } else {
                        break;
                    }
                }
            }
            if (cnt.size()) moveList.push_back(make_pair(make_pair(i, j), cnt));
        }
    }
    return moveList;
}

reversePiece choosePut(char myPiece, vector<reversePiece> candidate) {
    reversePiece ret = candidate[0];

    // 貪欲に選択
    for (int i = 0; i < candidate.size(); i++) {
        if (ret.second.size() < candidate[i].second.size()) {
            ret = candidate[i];
        } else if (ret.second.size() == candidate[i].second.size()) {
            if (myPiece == 'x') {
                // お菓子の魔女は下左を優先
                if (candidate[i].first.first > ret.first.first ||
                    (candidate[i].first.first == ret.first.first &&
                     candidate[i].first.second > ret.first.second))
                    ret = candidate[i];
            } else {
                // まみは上右を優先
                if (candidate[i].first.first < ret.first.first ||
                    (candidate[i].first.first == ret.first.first &&
                     candidate[i].first.second < ret.first.second))
                    ret = candidate[i];
            }
        }
    }
    return ret;
}

void turnOver(char myPiece, reversePiece selectPiece) {
    board[selectPiece.first.first][selectPiece.first.second] = myPiece;
    for (auto i : selectPiece.second) {
        board[i.first][i.second] = myPiece;
    }
}

void game() {
    // false でマミ
    bool turn = false;
    char myPiece, enemiesPiece;
    int skipCnt = 0;
    while (1) {
        if (turn) {
            myPiece = 'x';
            enemiesPiece = 'o';
        } else {
            myPiece = 'o';
            enemiesPiece = 'x';
        }
        // 動ける座標と候補を列挙
        vector<reversePiece> canditate = canMove(myPiece);
        // 打つ手がなければスキップ、どちらも打つ手がなければ終了
        if (!canditate.size()) {
            turn = !turn;
            skipCnt++;
            if (skipCnt == 2) break;
            continue;
        }
        skipCnt = 0;
        // 貪欲な方針に従って、選択
        reversePiece selectPiece = choosePut(myPiece, canditate);
        // ひっくり返す
        turnOver(myPiece, selectPiece);
        turn = !turn;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) {
            cin >> board[i][j];
        }
    }
    game();
    show();
}


Measured memory_bytes: 3228