#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
int main(){
    int k;
    std::cin >> k;
    std::vector<int> xx(k),yy(k);
    std::set<int> xs,ys;
    rep(i,8){
        xs.insert(i);
        ys.insert(i);
    }
    rep(i,k){
        std::cin >> xx[i]>>yy[i];
        //xx[i]--;yy[i]--;
        xs.erase(xx[i]);
        ys.erase(yy[i]);
    }
    std::vector<int> dx,dy;
    erep(i,xs){
        dx.pb(i);
    }
    erep(i,ys){
        dy.pb(i);
    }
    int n=8;
    vvector(db,bool,n,n,1);
    rep(ii,k){
        rep(i,n)db[xx[ii]][i]=0;
        rep(i,n)db[i][yy[ii]]=0;
        reprep(i,j,n,n){
            if(xx[ii]+yy[ii]==i+j)db[i][j]=0;
            if(xx[ii]-yy[ii]==i-j)db[i][j]=0;
        }
    }
   // erep(i,dy)std::cout << i << std::endl;
    do{
        std::vector<std::vector<bool>> b(db);
        bool dum=1;
        rep(ii,n-k){
            if(!b[dx[ii]][dy[ii]]){
                dum=0;
                break;
            }
            reprep(i,j,n,n){
                if(dx[ii]==i||dy[ii]==j)b[i][j]=0;
                if(dx[ii]+dy[ii]==i+j)b[i][j]=0;
                if(dx[ii]-dy[ii]==i-j)b[i][j]=0;
            }
        }
        if(dum){
            vvector(ans,char,n,n,'.');
            rep(i,n-k){
                ans[dx[i]][dy[i]]='Q';
            }
            rep(i,k){
                ans[xx[i]][yy[i]]='Q';
            }
            rep(i,n){
                rep(j,n){
                    std::cout << ans[i][j] ;
                }
                std::cout  << std::endl;
            }
            exit(0);
        }
    }while(next_permutation(all(dy)));
    
    
}


Measured memory_bytes: 3240