#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力

bool In_map(ll r,ll c){
    if(r>=0 && r<8 && c>=0 && c<8){
        return 1;
    }else{
        return 0;
    }
}

int main() {
    ll k;
    vector<vector<bool> > ans(8,vector<bool>(8));
    vector<vector<bool> > mp(8,vector<bool>(8));
    vector<vector<bool> > mp2(8,vector<bool>(8));
    vector<bool> rmap(8);
    vector<bool> cmap(8);
    cin >>k;
    vector<ll> r(k);
    vector<ll> c(k);
    rep(i,k){
        cin >> r[i]>>c[i];
    }

    rep(i,k){
        ans[r[i]][c[i]] = 1;
        rmap[r[i]] = 1;
        cmap[c[i]] = 1;
        rep(j,8){
            mp[r[i]][j] = 1;
        }

        rep(j,8){
            mp[j][c[i]] = 1;
        }
        ll j1=0;
        while(In_map(r[i]+j1,c[i]+j1)){
            mp[r[i]+j1][c[i]+j1] = 1;
            j1++;
        }
        j1=0;
        while(In_map(r[i]+j1,c[i]-j1)){
            mp[r[i]+j1][c[i]-j1] = 1;
            j1++;
        }
        j1=0;
        while(In_map(r[i]-j1,c[i]+j1)){
            mp[r[i]-j1][c[i]+j1] = 1;
            j1++;
        }
        j1=0;
        while(In_map(r[i]-j1,c[i]-j1)){
            mp[r[i]-j1][c[i]-j1] = 1;
            j1++;
        }
        j1=0;
    }
    mp2 = mp;
    vector<ll> a;
    vector<ll> an;
    rep(i,8){
        if(rmap[i] == 0)
            a.pb(i);
    }
    vector<ll> b;
    rep(i,8){
        if(cmap[i] == 0)
            b.pb(i);
    }
   
    
    do {
        mp = mp2;
        for (int i = 0; i < 8-k; i++) {
      
            if(mp[a[i]][b[i]] == 0){
                rep(j,8){
                    mp[a[i]][j] = 1;
                }

                rep(j,8){
                    mp[j][b[i]] = 1;
                }
                ll j1=0;
                while(In_map(a[i]+j1,b[i]+j1)){
                    mp[a[i]+j1][b[i]+j1] = 1;
                    j1++;
                }
                j1=0;
                while(In_map(a[i]+j1,b[i]-j1)){
                    mp[a[i]+j1][b[i]-j1] = 1;
                    j1++;
                }
                j1=0;
                while(In_map(a[i]-j1,b[i]+j1)){
                    mp[a[i]-j1][b[i]+j1] = 1;
                    j1++;
                }
                j1=0;
                while(In_map(a[i]-j1,b[i]-j1)){
                    mp[a[i]-j1][b[i]-j1] = 1;
                    j1++;
                }
                j1=0;
                ll tmp;
                /*cin >> tmp;
                rep(i,8){
                    rep(j,8){
                        if(mp[i][j]){
                            cout<<"Q";
                        }else{
                            cout <<".";
                        }
                    }
                    cout <<endl;
                }*/
            }else{
                //cout<<"break"<<endl;;
                break;
            }
            if(i == 7-k){
                an = a;
            }
        }

    } while(next_permutation(all(a)));

    rep(i,8-k){
        ans[an[i]][b[i]] = 1;
    }
    
    rep(i,8){
        rep(j,8){
            if(ans[i][j]){
                cout<<"Q";
            }else{
                cout <<".";
            }
        }
        cout <<endl;
    }
    return 0;
    

}


Measured memory_bytes: 3156