#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

vector<ll> vx = {0, 0, 1, -1, 1, 1, -1, -1};
vector<ll> vy = {1, -1, 0, 0, 1, -1, 1, -1};

bool checkline(ll x, ll y, ll dx, ll dy, vector<string>& tmp)
{
    ll nextx = x;
    ll nexty = y;
    while (1)
    {
        nextx += dx;
        nexty += dy;
        if (!(nextx < tmp[0].size() && nextx >= 0 && nexty < tmp.size() && nexty >= 0))
        {
            return 0;
        }
        if (tmp[nexty][nextx] == 'Q')
        {
            return 1;
        }
    }
}

void fillline(ll x, ll y, ll dx, ll dy)
{
    ll nextx = x;
    ll nexty = y;
    while (1)
    {
        nextx += dx;
        nexty += dy;
        if (!(nextx < g[0].size() && nextx >= 0 && nexty < g.size() && nexty >= 0))
        {
            return;
        }
        g[nexty][nextx] = 'x';
    }
}

bool check(vector<P>& used)
{
    vector<string> tmp = g;
    for (int i = 0; i < used.size(); ++i)
    {
        tmp[used[i].first][used[i].second] = 'Q';
    }
    for (int i = 0; i < used.size(); ++i)
    {
        for (int j = 0; j < vx.size(); ++j)
        {
            bool failed = checkline(used[i].second, used[i].first, vx[j], vy[j], tmp);
            if (failed)
            {
                return failed;
            }
        }
    }
    return 0;
}

void fill(ll x, ll y)
{
    for (int i = 0; i < vx.size(); ++i)
    {
        fillline(x, y, vx[i], vy[i]);
    }
}
int main() {


    
    g = vector<string>(8, string(8, '.'));
    
    ll n;
    cin >> n;
    vector<P> used;
    for (int i = 0; i < n; ++i)
    {
        ll x, y;
        cin >> y >> x;
        g[y][x] = 'Q';
        fill(x, y);
    }
    
    for (int i = 0; i < 8; ++i)
    {
        if (g[0][i] != '.' && g[0][i] != 'Q')
        {
            continue;
        }
        for (int j = 0; j < 8; ++j)
        {
            if (g[1][j] != '.' && g[1][j] != 'Q')
            {
                continue;
            }
            for (int k = 0; k < 8; ++k)
            {
                if (g[2][k] != '.' && g[2][k] != 'Q')
                {
                    continue;
                }
                for (int l = 0; l < 8; ++l)
                {
                    if (g[3][l] != '.' && g[3][l] != 'Q')
                    {
                        continue;
                    }
                    for (int m = 0; m < 8; ++m)
                    {
                        if (g[4][m] != '.' && g[4][m] != 'Q')
                        {
                            continue;
                        }
                        for (int n = 0; n < 8; ++n)
                        {
                            if (g[5][n] != '.' && g[5][n] != 'Q')
                            {
                                continue;
                            }
                            for (int o = 0; o < 8; ++o)
                            {
                                if (g[6][o] != '.' && g[6][o] != 'Q')
                                {
                                    continue;
                                }
                                for (int p = 0; p < 8; ++p)
                                {
                                    if (g[7][p] != '.' && g[7][p] != 'Q')
                                    {
                                        continue;
                                    }
                                    vector<P> utmp = used;
                                    utmp.push_back(P(0, i));
                                    utmp.push_back(P(1, j));
                                    utmp.push_back(P(2, k));
                                    utmp.push_back(P(3, l));
                                    utmp.push_back(P(4, m));
                                    utmp.push_back(P(5, n));
                                    utmp.push_back(P(6, o));
                                    utmp.push_back(P(7, p));
                                    bool c = check(utmp);
                                    if (!c)
                                    {
                                        vector<string> ret(8, string(8, '.'));
                                        for (int q = 0; q < utmp.size(); ++q)
                                        {
                                            ret[utmp[q].first][utmp[q].second] = 'Q';
                                        }
                                        for (int q = 0; q < ret.size(); ++q)
                                        {
                                            cout << ret[q] << endl;
                                        }
                                        return 0;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3244