#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <deque>
#include <iomanip>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <bitset>

/*----------------------------------------------------------------*/

using ld = long double;
using vld = std::vector<ld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using str = std::string;
using vstr = std::vector<str>;
using vb = std::vector<bool>;
using vvb = std::vector<vb>;

/*----------------------------------------------------------------*/

template<class T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<class T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }
template<class T> T square(T a) { return a * a; }

/*----------------------------------------------------------------*/

constexpr ld PI = 3.141592653589793L;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e12;

/*----------------------------------------------------------------*/

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
ll ctz(ll n) { ll ans = 0; for (; ~n & 1; n >>= 1) ans++; return ans; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll popcnt(ll n) {
    n = ((n & 0xaaaaaaaaaaaaaaaa) >> 1) + (n & 0x5555555555555555);
    n = ((n & 0xcccccccccccccccc) >> 2) + (n & 0x3333333333333333);
    n = ((n & 0xf0f0f0f0f0f0f0f0) >> 4) + (n & 0x0f0f0f0f0f0f0f0f);
    n = ((n & 0xff00ff00ff00ff00) >> 8) + (n & 0x00ff00ff00ff00ff);
    n = ((n & 0xffff0000ffff0000) >> 16) + (n & 0x0000ffff0000ffff);
    n = ((n & 0xffffffff00000000) >> 32) + (n & 0x00000000ffffffff);
    return n;
}
str zfill(str s, ll n) { return str(n - s.length(), '0') + s; }
ll to_ll(char c) { return (ll)c - '0'; }
ll to_ll(str s) {
    ll ans = 0;
    for (ll i = 0; i < s.length(); i++)
        ans = 10 * ans + to_ll(s[i]);
    return ans;
}

/*----------------------------------------------------------------*/

void Solve();

/*----------------------------------------------------------------*/

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    Solve();
}

void Solve() {
    vvb v(8, vb(8, false));

    ll k; std::cin >> k;

    vll r(k), c(k);
    for (ll i = 0; i < k; i++) {
        std::cin >> r[i] >> c[i];
        v[r[i]][c[i]] = true;
    }

    vll w(8 - k), x(8 - k);
    for (ll i = 0, j = 0; i < 8; i++)
        if (std::find(r.begin(), r.end(), i) == r.end())
            w[j++] = i;
    for (ll i = 0, j = 0; i < 8; i++)
        if (std::find(c.begin(), c.end(), i) == c.end())
            x[j++] = i;

    const vll dr = { -1, -1, -1, 0, 1, 1, 1, 0 };
    const vll dc = { -1, 0, 1, 1, 1, 0, -1, -1 };

    auto f = [](ll n) { return 0 <= n && n < 8; };

    auto g = [=](vvb v, ll r, ll c) {
        for (ll i = 0; i < 8; i++) {
            for (ll j = 1; f(r + j * dr[i]) && f(c + j * dc[i]); j++)
                if (v[r + j * dr[i]][c + j * dc[i]])
                    return false;
        }
        return true;
    };

    do {
        vvb temp = v;
        for (ll i = 0; i < 8 - k; i++)
            temp[w[i]][x[i]] = true;
        bool flag = true;
        for (ll i = 0; i < 64; i++) {
            ll row = i / 8, col = i % 8;
            if (temp[row][col] && !g(temp, row, col)) {
                flag = false; break;
            }
        }
        if (flag) { v = temp; break; }
    } while (std::next_permutation(x.begin(), x.end()));

    for (ll i = 0; i < 8; i++) {
        for (ll j = 0; j < 8; j++)
            std::cout << (v[i][j] ? 'Q' : '.');
        std::cout << '\n';
    }
}



Measured memory_bytes: 3232