#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int kyomu;
    cin >> kyomu;
    vector<vector<int>> board(8, vector<int>(8, 0));
    for(int i = 0; i < kyomu; ++i){
        int r, c;
        cin >> r >> c;
        board[r][c] = 1;
    }
    vector<vector<bool>> ng(8, vector<bool>(8, false));
    for(int x = 0; x < 8; ++x){
        for(int y = 0; y < 8; ++y){
            if(!board[x][y])    continue;
            ng[x][y] = true;
            for(int i = 0; i < 8; ++i){
                int nx = x, ny = y;
                for(int j = 0; j < 8; ++j){
                    nx += dx[i], ny += dy[i];
                    if(nx < 0 || nx >= 8 || ny < 0 || ny >= 8)  break;
                    ng[nx][ny] = true;
                }
            }
        }
    }

    auto dfs = [&](auto&& self, int T) -> bool {
        if(T == 8)  return true;

        vector<int> xs, ys;
        for(int x = 0; x < 8; ++x){
            for(int y = 0; y < 8; ++y){
                if(ng[x][y])    continue;
                xs.emplace_back(x);
                ys.emplace_back(y);
            }
        }

        int n = xs.size();
        for(int i = 0; i < n; ++i){
            board[xs[i]][ys[i]] = 1;
            vector<int> prex, prey;
            ng[xs[i]][ys[i]] = true;
            prex.emplace_back(xs[i]);
            prey.emplace_back(ys[i]);
            for(int j = 0; j < 8; ++j){
                int nx = xs[i], ny = ys[i];
                for(int k = 0; k < 8; ++k){
                    nx += dx[j], ny += dy[j];
                    if(nx < 0 || nx >= 8 || ny < 0 || ny >= 8)  break;
                    if(ng[nx][ny])  continue;
                    ng[nx][ny] = true;
                    prex.emplace_back(nx);
                    prey.emplace_back(ny);
                }
            }
            if(self(self, T + 1))   return true;
            else{
                board[xs[i]][ys[i]] = 0;
                int m = prex.size();
                for(int j = 0; j < m; ++j)  ng[prex[j]][prey[j]] = false;
            }
        }
        return false;
    };

    dfs(dfs, kyomu);
    
    for(int i = 0; i < 8; ++i){
        for(int j = 0; j < 8; ++j){
            if(board[i][j]) cout << 'Q';
            else    cout << '.';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3212