#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int SIZE = 8;
enum Turn{MAMI, MAJO, };
const int dx[] = {0, 0, -1, -1, -1, 1, 1, 1};
const int dy[] = {1 ,-1, 1, 0, -1, 1, 0, -1};

bool inside(const int ii, const int jj) {
    return 0 <= ii && ii < SIZE && 0 <= jj && jj < SIZE;
}

Turn change(Turn now) {
    switch (now) {
    case MAMI:
        return MAJO;
        break;
    case MAJO:
        return MAMI;
        break;
    }
}

bool check(vector<string> S, Turn now) {
    char target = (now == MAMI ? 'x' : 'o');
    char me = (target == 'o' ? 'x' : 'o');
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (S[i][j] == '.') {
                for (int d = 0; d < 8; d++) {
                    int ni = i + dx[d];
                    int nj = j + dy[d];
                    int cnt = 0;
                    while (inside(ni, nj) && S[ni][nj] == target) {
                        ni += dx[d];
                        nj += dy[d];
                        cnt++;
                    }
                    if (inside(ni, nj) && S[ni][nj] == me && cnt != 0) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}

using State = pair<pair<int, int>, vector<string>>;//<<revnum, point>, board>
//point MAMI ?????¨????¬?????????¢
State change(vector<string> S, int i, int j, Turn now) {
    char target = (now == MAMI ? 'x' : 'o');
    char me = (target == 'o' ? 'x' : 'o');
    State res;
    const int idx1d = i * SIZE + j;
    res.first = make_pair(0, (now == MAMI ? -idx1d : idx1d));
    assert(S[i][j] == '.');
    S[i][j] = me;
    for (int d = 0; d < 8; d++) {
        int ni = i + dx[d];
        int nj = j + dy[d];
        int cnt = 0;
        while (inside(ni, nj) && S[ni][nj] == target) {
            ni += dx[d];
            nj += dy[d];
            cnt++;
        }
        if (inside(ni, nj) && S[ni][nj] == me && cnt != 0) {
            res.first.first += cnt;
            for (int rev = 0, ii = i + dx[d], jj = j + dy[d]; rev < cnt; rev++, ii += dx[d], jj += dy[d]) {
                assert(S[ii][jj] == target);
                S[ii][jj] = me;
            }
        }
    }
    res.second = S;
    return res;
}

vector<string> play(vector<string> S, Turn now) {
    priority_queue<State> pq;
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (S[i][j] == '.') {
                State res = change(S, i, j, now);
                if (res.first.first != 0) {
                    pq.push(res);
                }
            }
        }
    }
    return pq.top().second;
}

int main(void) {
    vector<string> S(SIZE);
    for (int i = 0; i < SIZE; i++) {
        cin >> S[i];
    }
    bool prevSkip = false;
    Turn now = MAMI;
    int cnt = 0;
    while (true) {
        //DEBUG(cnt++)
        if (!check(S, now)) {
            if (prevSkip) break;
            prevSkip = true;
            now = change(now);
            continue;
        }
        prevSkip = false;
        S = play(S, now);
        now = change(now);

        // for (int i = 0; i < SIZE; i++) {
        //     cout << S[i] << endl;
        // }
    }
    for (int i = 0; i < SIZE; i++) {
        cout << S[i] << endl;
    }
}

Measured memory_bytes: 3244