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

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// input
inline int inputi(){ int x; scanf("%d", &x); return x; }
inline ll inputl(){ ll x; scanf("%lld", &x); return x; }
inline double inputd(){ double x; scanf("%lf", &x); return x; }
inline string inputs(){ string x; cin >> x; return x; }
template <class T> inline T input(){ T x; cin >> x; return x; }

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) obj.size()
#define sza(ary) (sizeof(ary) / sizeof(*ary))
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(ary) memset((ary), 0, sizeof(ary))

// print util
#define print(x) cout << (x) << endl
#define printd(x, d) cout << fixed << setprecision(d) << (x) << endl
#define printv(v) REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1]
#define printa(ary) REP(i, sza(ary)) cout << ary[i] << "\n "[i < sza(ary) - 1]
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

vector<string> board(8);

bool in_board(int y, int x)
{
    return 0 <= y && y < 8 && 0 <= x && x < 8;
}

int get(int y, int x, bool mami, int dy, int dx)
{
    int cnt = 0;
    do {
        y += dy;
        x += dx;
        cnt++;
    } while (in_board(y, x) && board[y][x] == "ox"[mami]);
    if (in_board(y, x) && board[y][x] == "xo"[mami]){
        return cnt - 1;
    }
    else {
        return 0;
    }
}

int get(int y, int x, bool mami)
{
    if (board[y][x] != '.') return 0;
    int cnt = 0;
    FOR(i, -1, 2) FOR(j, -1, 2){
        if (!(i | j)){
            continue;
        }
        cnt += get(y, x, mami, i, j);
    }
    return cnt;
}

void put(int y, int x, bool mami, int dy, int dx)
{
    int cnt = 0;
    do {
        y += dy;
        x += dx;
        cnt++;
    } while (in_board(y, x) && board[y][x] == "ox"[mami]);
    if (!in_board(y, x) || board[y][x] != "xo"[mami]) return;
    while (--cnt){
        y -= dy;
        x -= dx;
        board[y][x] = "xo"[mami];
    }
}

void put(int y, int x, bool mami)
{
    board[y][x] = "xo"[mami];
    FOR(i, -1, 2) FOR(j, -1, 2){
        if (!(i | j)){
            continue;
        }
        put(y, x, mami, i, j);
    }
}

bool put(bool mami)
{
    int maxi = 0;
    pii p;
    if (mami){
        REP(i, 8) REP(j, 8){
            int tmp = get(i, j, mami);
            if (maxi < tmp){
                maxi = tmp;
                p = pii(i, j);
            }
        }
    }
    else {
        RREP(i, 8) RREP(j, 8){
            int tmp = get(i, j, mami);
            if (maxi < tmp){
                maxi = tmp;
                p = pii(i, j);
            }
        }
    }
    if (maxi){
        // cout << "xo"[mami] << " " << p.fst << " " << p.sec << '\n';
        put(p.fst, p.sec, mami);
        return true;
    }
    else return false;
}

signed main()
{
    REP(i, 8) cin >> board[i];
    bool mami = true;
    bool passed = false;
    while (1){
        if (!put(mami)){
            if (passed) break;
            else passed = true;
            // cout << "xo"[mami] << " passed" << '\n';
        }
        else {
            passed = false;
        }
        // REP(i, 8) cout << board[i] << '\n';
        // cout << '\n';
        mami = !mami;
    }
    REP(i, 8) cout << board[i] << '\n';

    return 0;
}

Measured memory_bytes: 1172