#include <iostream>
#include <numeric>

using namespace std;

int main() {
    int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
    int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
    int x_best, y_best, most_got, got_count;
    char s[8][8];
    bool is_changed[2] = {true, true};
    char mine[2] = {'o', 'x'};
    char yours[2] = {'x', 'o'};
    for (int x=0; x<8; x++) {
        for (int y=0; y<8; y++) {
            cin >> s[x][y];
        }
    }
    while (is_changed[0] || is_changed[1]) {
        for (int player=0; player<2; player++) {
            is_changed[player] = false;
            most_got = 0;
            for (int x=0; x<8; x++) {
                for (int y=0; y<8; y++) {
                    if (s[x][y] != '.') {
                        continue;
                    }
                    got_count = 0;
                    for (int i=0; i<8; i++) {
                        int x_cur = x;
                        int y_cur = y;
                        int k = 0;
                        while (true) {
                            x_cur += dx[i];
                            y_cur += dy[i];
                            k++;
                            if (x_cur < 0 || y_cur < 0 || x_cur > 7 || y_cur > 7) {
                                break;
                            }
                            if (s[x_cur][y_cur] != yours[player]) {
                                if (s[x_cur][y_cur] == mine[player]) {
                                    got_count += k-1;
                                }
                                break;
                            }
                        }
                    }
                    if ((player == 0 && got_count > most_got)
                        || (player == 1 && got_count >= most_got && got_count > 0)) {
                        x_best = x;
                        y_best = y;
                        most_got = got_count;
                        is_changed[player] = true;
                    }
                }
            }
            if (is_changed[player]) {
                for (int i=0; i<8; i++) {
                    int x_cur = x_best;
                    int y_cur = y_best;
                    int k = 0;
                    while (true) {
                        x_cur += dx[i];
                        y_cur += dy[i];
                        k++;
                        if (x_cur < 0 || y_cur < 0 || x_cur > 7 || y_cur > 7) {
                            break;
                        }
                        if (s[x_cur][y_cur] != yours[player]) {
                            if (s[x_cur][y_cur] == mine[player] && k > 1) {
                                while (true) {
                                    x_cur -= dx[i];
                                    y_cur -= dy[i];
                                    if (s[x_cur][y_cur] != yours[player]) {
                                        break;
                                    }
                                    s[x_cur][y_cur] = mine[player];
                                }
                                s[x_best][y_best] = mine[player];
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    for (int x=0; x<8; x++) {
        for (int y=0; y<8; y++) {
            cout << s[x][y];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1136