#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int _flip(vvc& field, bool turn, int x, int y, int d) {
    char cookie = turn ? 'o' : 'x';
    char other_cookie = !turn ? 'o' : 'x';
    if (0 <= x && x < 8 && 0 <= y && y < 8 && field[y][x] != '.') {
        if (field[y][x] == other_cookie) {
            int cnt = _flip(field, turn, x+dx[d], y+dy[d], d);
            if (cnt == -1) {
                return -1;
            }
            field[y][x] = cookie;
            return cnt+1;
        } else {
            return 0;
        }
    }
    return -1;
}

bool flip(vvc& field, bool turn) {
    int ma = 0;
    int X = -1, Y = -1;
    char cookie = turn ? 'o' : 'x';
    char other_cookie = !turn ? 'o' : 'x';
    if (turn) {
        REP(y, 8) REP(x, 8) {
            if (field[y][x] != '.') continue;
            bool ok = false;
            REP(i, 8) {
                int sx = x + dx[i], sy = y + dy[i];
                if (0 <= sx && sx < 8 && 0 <= sy && sy < 8 && field[sy][sx] == other_cookie) {
                    ok = true;
                }
            }
            if (ok) {
                vvc _field = field;
                int cnt = 0;
                REP(i, 8) {
                    int sx = x + dx[i], sy = y + dy[i];
                    cnt += max(0, _flip(_field, turn, sx, sy, i));
                }
                if (ma < cnt) {
                    ma = cnt;
                    X = x;
                    Y = y;
                }
            }
        }
    } else {
        RREP(y, 8) RREP(x, 8) {
            if (field[y][x] != '.') continue;
            bool ok = false;
            REP(i, 8) {
                int sx = x + dx[i], sy = y + dy[i];
                if (0 <= sx && sx < 8 && 0 <= sy && sy < 8 && field[sy][sx] == other_cookie) {
                    ok = true;
                }
            }
            if (ok) {
                vvc _field = field;
                int cnt = 0;
                REP(i, 8) {
                    int sx = x + dx[i], sy = y + dy[i];
                    cnt += max(0, _flip(_field, turn, sx, sy, i));
                }
                if (ma < cnt) {
                    ma = cnt;
                    X = x;
                    Y = y;
                }
            }
        }
    }
    if (X == -1) return false;
    field[Y][X] = cookie;
    REP(i, 8) {
        int sx = X + dx[i], sy = Y + dy[i];
        _flip(field, turn, sx, sy, i);
    }
    return true;
}

int main() {
    vvc field(8, vc(8));
    REP(y, 8) REP(x, 8) cin >> field[y][x];

    bool turn = true;
    bool passed = false;
    while (1) {
        if (!flip(field, turn)) {
            if (passed) break;
            passed = true;
        } else {
            passed = false;
        }
        turn = !turn;
    }
    REP(y, 8) {
        REP(x, 8) {
            printf("%c", field[y][x]);
        }
        printf("\n");
    }
}

Measured memory_bytes: 3100