#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

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

bool ExsistQueen(char squre[8][8],int x,int y){
  int ii,jj,nx,ny;

//  for(ii=0;ii<8;ii++){
//    if(squre[ii][x] == 1 && ii != y){
//      return true;
//    }
//  }
//
//  for(ii=0;ii<8;ii++){
//    if(squre[y][ii] == 1 && ii != x){
//      return true;
//    }
//  }
  
  for(jj=0;jj<7;jj++){
    //左上
    for(ii=1;ii<8;ii++){
      nx = x + dx[jj] * ii;
      ny = y + dy[jj] * ii;
    
      if(nx <= -1 || ny <=-1 || nx >= 8 ||  ny >= 8){
        break;
      }
      
      if(squre[ny][nx] == 1){
        return true;
      }
    }
  }
  
  return false;
  
}

bool IsEightQueenOk(char squre[8][8]){
  int ii,jj;
  for(ii=0;ii<8;ii++){
    for(jj=0;jj<8;jj++){
      if(squre[ii][jj] == 1){
        if(ExsistQueen(squre,jj,ii)){
          return false;
        }
      }
    }
  }
  return true;
}

vector<vector<int>> combi(int n,int r){
  vector<vector<int>> ret;
  vector<int> tmp;
  int ii,jj;
  int cnt;
  
  for(ii=0;ii<pow(2,n);ii++){
    //cout << "ii:" << ii << endl;
    cnt = 0;
    tmp.clear();

    for(jj=0;jj<n;jj++){
      //cout << "jj:" << jj << "," ;
      if( ((ii >> jj) & 1) == 1){
        cnt++;
        tmp.push_back(jj);
      }
      else{

      }
    }
    //cout << endl;
    if(cnt == r){
      //cout << "push_back" << endl;
      ret.push_back(tmp);
    }

  }
  
  return ret;
}

int main(){
  vector<vector<int>> com;
  long ii,jj,kk;
  vector<int> ret;
  int seq[10];
  int seq2[10];
  char squre[8][8];
  int k;
  vector<int> x,y;
  // 8 Queen Problem
  cin >> k;

  x.resize(k);
  y.resize(k);
  for(ii=0;ii<k;ii++){
    cin >> y[ii] >> x[ii];
  }
  
  int pos=0;
  memset(seq,0,sizeof(seq));
  memset(seq2,0,sizeof(seq2));

//  for(ii=0;ii<k;ii++){
//    printf("x=%d y=%d\n",x[ii],y[ii]);
//  }

  for(ii=0;ii<8;ii++){


    if(find(y.begin(),y.end(),ii) == y.end()){
      seq[pos] = ii;
      pos++;
    }
  }

  pos =0;
  for(ii=0;ii<8;ii++){
    if(find(x.begin(),x.end(),ii) == x.end()){
      seq2[pos] = ii;
      pos=pos+1;
    }

  }
  
//  for(ii=0;ii<8-k;ii++){
//    printf("x=%d y=%d pos=%d\n",seq[ii],seq2[ii],pos);
//  }
  
  do{
    do{
      memset(squre,0,sizeof(squre));

      for(ii=0;ii<8-k;ii++){
        squre[seq[ii]][seq2[ii]] = 1;
      }
      
      for(ii=0;ii<k;ii++){
        squre[y[ii]][x[ii]] = 1;
      }
      
      //printf("=============\n");
      //
      //for(ii=0;ii<8;ii++){
      //  for(jj=0;jj<8;jj++){
      //    printf("%d ",squre[ii][jj]);
      //  }
      //  printf("\n");
      //}
      //
      //printf("===============\n");
      if(IsEightQueenOk(squre)){
        //cout << "ok!!" << endl;
        goto end;
      }
      
    }while(next_permutation(seq,seq+(pos)));
  }while(next_permutation(seq2,seq2+(pos)));

 end:
  for(ii=0;ii<8;ii++){
    for(jj=0;jj<8;jj++){
      if(squre[ii][jj] == 1){
        printf("Q");
      }
      else{
        printf(".");
      }

    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 3092