#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define BLACK 1 // マミ：先行
#define WHITE -1 // カマンベール：後攻
#define WALL 2
#define EMPTY 0
#define BOARD 8

typedef long long ll;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int board[BOARD+2][BOARD+2];

int ABS(int a) {
    if (a < 0) return -a;
    else return a;
}

int main(void) {
    // 壁の作成
    for (int i = 0; i < 10; i++) {
        board[0][i] = WALL;
        board[BOARD+1][i] = WALL;
        board[i][0] = WALL;
        board[i][BOARD+1] = WALL;
    }
    int cnt = 0;
    // boardの作成
    string str;
    for (int i = 0; i < 8; i++) {
        cin >> str;
        for (int j = 0; j < 8; j++) {
            if (str[j] == '.') board[i+1][j+1] = EMPTY;
            else if (str[j] == 'o') board[i+1][j+1] = BLACK;
            else board[i+1][j+1] = WHITE;
        }
    }
    // 解の主軸
    while (1) {
        bool black_pass_flag = false, white_pass_flag = false;
        // 巴マミ
        // 最大になるところを探す
        int ma = 0, x_index = 0, y_index = 0;
        for (int y = 1; y <= 8; y++) {
            for (int x = 1; x <= 8; x++) {
//                printf("(%d %d)\n", x, y);
                if (board[y][x] != EMPTY) {
//                    cout << "not empty so continue" << endl;
                    continue;
                }
                int num = 0;
                for (int i = 0; i < 8; i++) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (board[ny][nx] != WHITE) {
                        continue;
                    }
                    while (board[ny][nx] == WHITE) {
                        ny += dy[i];
                        nx += dx[i];
                    }
                    if (board[ny][nx] == BLACK) {
//                        printf("find black\n");
                        //cout << nx << " " << ny << endl;
                        num += max(ABS(ny - y), ABS(nx - x)) - 1;
                    }
                }
                if (ma < num) {
                    ma = num;
                    x_index = x;
                    y_index = y;
                }
            }
        }
//        printf("max:%d index:(%d,%d)\n", ma, x_index, y_index);
        if (ma == 0) black_pass_flag = true;
        else {
        // 最大になるところに黒を置いてひっくり返す
            board[y_index][x_index] = BLACK;
            for (int i = 0; i < 8; i++) {
                int nx = x_index + dx[i];
                int ny = y_index + dy[i];
                if (board[ny][nx] != WHITE) continue;
                while (board[ny][nx] == WHITE) {
                    ny += dy[i];
                    nx += dx[i];
                }
                if (board[ny][nx] == BLACK) {
                    for (int x = x_index, y = y_index; x != nx || y != ny; x += dx[i], y += dy[i]) {
                        board[y][x] = BLACK;
                    }
                }
            }
        }
        // カマンベール
        // 最大になるところを探す
        ma = 0, x_index = 0, y_index = 0;
        for (int y = 8; y >= 1; y--) {
            for (int x = 8; x >= 1; x--) {
//                printf("(%d %d)\n", x, y);
                if (board[y][x] != EMPTY) {
//                    cout << "not empty so continue" << endl;
                    continue;
                }
                int num = 0;
                for (int i = 0; i < 8; i++) {
                    int nx = x + dx[i];
                    int ny = y + dy[i];
                    if (board[ny][nx] != BLACK) {
                        continue;
                    }
                    while (board[ny][nx] == BLACK) {
                        ny += dy[i];
                        nx += dx[i];
                    }
                    if (board[ny][nx] == WHITE) {
//                        printf("find black\n");
                        //cout << nx << " " << ny << endl;
                        num += max(ABS(ny - y), ABS(nx - x)) - 1;
                    }
                }
                if (ma < num) {
                    ma = num;
                    x_index = x;
                    y_index = y;
                }
            }
        }
//        printf("max:%d index:(%d,%d)\n", ma, x_index, y_index);
        if (ma == 0) white_pass_flag = true;
        else {
        // 最大になるところに黒を置いてひっくり返す
            board[y_index][x_index] = WHITE;
            for (int i = 0; i < 8; i++) {
                int nx = x_index + dx[i];
                int ny = y_index + dy[i];
                if (board[ny][nx] != BLACK) continue;
                while (board[ny][nx] == BLACK) {
                    ny += dy[i];
                    nx += dx[i];
                }
                if (board[ny][nx] == WHITE) {
                    for (int x = x_index, y = y_index; x != nx || y != ny; x += dx[i], y += dy[i]) {
                        board[y][x] = WHITE;
                    }
                }
            }
        }
        if (black_pass_flag && white_pass_flag) break;
    }

    // output
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) {
            if (board[i][j] == BLACK) cout << "o";
            else if (board[i][j] == WHITE) cout << "x";
            else cout << ".";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1180