#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int cnt(vector<string>& matrix, int now_h, int now_w, int dh, int dw, char target) {
    int now_cnt = 0;
    for (; now_h < matrix.size() && now_h >= 0 && now_w < matrix[0].size() && now_w >= 0; now_h += dh, now_w += dw) {
        if (matrix[now_h][now_w] == '.') return 0;
        else if (matrix[now_h][now_w] == target) return now_cnt;
        else {
            matrix[now_h][now_w] = target;
            now_cnt++;
        }
    }
    return 0;
}

int all_cnt(vector<string>& matrix, int now_h, int now_w, char target) {
    int dh[3] = {-1, 0, 1};
    int dw[3] = {-1, 0, 1};
    int res = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (i == 1 && j == 1) continue;
            vector<string> tmp(matrix);
            int now_cnt = cnt(tmp, now_h + dh[i], now_w + dw[j], dh[i], dw[j], target);
            if (now_cnt > 0) {
                matrix = tmp;
                res += now_cnt;
            }
        }
    }
    return res;
}

bool mami_comp(const pair<int, P>& l, const pair<int, P>& r) {
    if (l.first != r.first) return l.first > r.first;
    if (l.second.first != r.second.first) return l.second.first < r.second.first;
    return l.second.second < r.second.second;
}

bool majo_comp(const pair<int, P>& l, const pair<int, P>& r) {
    if (l.first != r.first) return l.first > r.first;
    if (l.second.first != r.second.first) return l.second.first > r.second.first;
    return l.second.second > r.second.second;
}

bool mami_ok(vector<string>& matrix) {
    vector<PP> candidate;
    for (int i = 0; i < matrix.size(); i++) {
        for (int j = 0;  j < matrix[i].size(); j++) {
            if (matrix[i][j] != '.') continue;
            vector<string> tmp(matrix);
            int now_cnt = all_cnt(tmp, i, j, 'o');
            if (now_cnt == 0) continue;
            candidate.push_back(PP(now_cnt, P(i, j)));
        }
    }
    if (candidate.size() == 0) return false;
    sort(candidate.begin(), candidate.end(), mami_comp);
    int final_h = candidate[0].second.first, final_w = candidate[0].second.second;
    matrix[final_h][final_w] = 'o';
    all_cnt(matrix, final_h, final_w, 'o');
    return true;
}

bool majo_ok(vector<string>& matrix) {
    vector<PP> candidate;
    for (int i = 0; i < matrix.size(); i++) {
        for (int j = 0;  j < matrix[i].size(); j++) {
            if (matrix[i][j] != '.') continue;
            vector<string> tmp(matrix);
            int now_cnt = all_cnt(tmp, i, j, 'x');
            if (now_cnt == 0) continue;
            candidate.push_back(PP(now_cnt, P(i, j)));
        }
    }
    if (candidate.size() == 0) return false;
    sort(candidate.begin(), candidate.end(), majo_comp);
    int final_h = candidate[0].second.first, final_w = candidate[0].second.second;
    matrix[final_h][final_w] = 'x';
    all_cnt(matrix, final_h, final_w, 'x');
    return true;
}

void solve() {
    vector<string> grid(8);
    for (int i = 0 ; i < 8; i++) {
        cin >> grid[i];
    }
    char targets[2] = {'o', 'x'};
    int now = 0;
    bool can_change = true;
    while (true) {
        bool is_fin = false;
        if (mami_ok(grid)) can_change = true;
        else {
            if (!can_change) is_fin = true;
            else can_change = false;
        }
        if (is_fin) break;
        now ^= 1;
        if (majo_ok(grid)) can_change = true;
        else {
            if (!can_change) is_fin = true;
            else can_change = false;
        }
        if (is_fin) break;
        now ^= 1;
    }
    for (int i = 0; i < 8; i++) {
        cout << grid[i] << endl;
    }
}

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


Measured memory_bytes: 3236