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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;

const int H = 8;
const int W = 8;
char board[H][W];
int dp[H][W];

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

char getOpposite(char player) {
    return (player == 'o') ? 'x' : 'o';
}

// check if (x, y) is occupied by the opponent
bool isOpposite(int x, int y, char player) {
    return board[x][y] == getOpposite(player);
}

// update max when one of the end is (x, y)
void updateDP(int x, int y, char player) {
    rep(k, 8) {
        int cnt = 0;
        int nx = x + dx[k], ny = y + dy[k];

        while (inside(nx, ny) && isOpposite(nx, ny, player)) {
            cnt++;
            nx += dx[k], ny += dy[k];
        }
        if (inside(nx, ny) && board[nx][ny] == '.') {
            dp[nx][ny] += cnt;
        }
    }
}

P getMaxId(char player) {
    int max_x = -1;
    int max_y = -1;
    int max_num = 0;

    if (player == 'o') {
        rep(i, H) {
            rep(j, W) {
                if (dp[i][j] > max_num) {
                    max_num = dp[i][j];
                    max_x = i;
                    max_y = j;
                }
            }
        }
    } else {
        rrep(i, H) {
            rrep(j, W) {
                if (dp[i][j] > max_num) {
                    max_num = dp[i][j];
                    max_x = i;
                    max_y = j;
                }
            }
        }
    }

    return P(max_x, max_y);
}

void place(int x, int y, char player) {
    board[x][y] = player;
    rep(k, 8) {
        int cnt = 0;
        int nx = x + dx[k], ny = y + dy[k];

        while (inside(nx, ny) && isOpposite(nx, ny, player)) {
            cnt++;
            nx += dx[k], ny += dy[k];
        }
        if (inside(nx, ny) && board[nx][ny] == player) {
            while (cnt > 0) {
                nx -= dx[k], ny -= dy[k];
                board[nx][ny] = player;
                cnt--;
            }
        }
    }
}

void initDP() {
    rep(i, H) rep(j, W) dp[i][j] = 0;
}

// is pass, then return false
bool play(char player) {
    initDP();

    rep(i, H) {
        rep(j, W) {
            if (board[i][j] == player) {
                updateDP(i, j, player);
            }
        }
    }

    P p = getMaxId(player);
    int max_x = p.first, max_y = p.second;

    if (max_x != -1) {
        place(max_x, max_y, player);
        return true;
    }
    return false;
}


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

    rep(i, H) {
        string s;
        cin >> s;
        rep(j, W) board[i][j] = s[j];
    }

    bool updated = true;
    while (updated) {
        bool up1 = play('o');
        bool up2 = play('x');
        updated = up1 || up2;
    }

    rep(i, H) {
        rep(j, W) {
            cout << board[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3228