#include<stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
 
int x[N][N];
void initialize(void);
void printBoard(void);
void recursive(int);
 
int main(){
  int i,j;
   
  initialize();
 
  for( i = 0 ; i < N ; i++ ){
    for(j = 0 ; j < N ; j++ ){
      x[i][j] = 0;
 
    }
  }
 
  int k;
  int r,c;
   
  scanf("%d",&k);
 
  for( i = 0 ; i < k ; i++ ){
    scanf("%d%d",&r,&c);
    x[r][c] = 1;
  }
 
  recursive(0);
 
  return 0;
}
 
void initialize(){
  int i,j;
  for( i = 0 ; i < N ; i++ ) {
    row[i] = FREE;
    col[i] = FREE;
  }
 
  for( i = 0 ; i < 2*N-1 ; i++ ){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
 
}
 
 
void printBoard(){
  int i,j;
   
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(x[i][j]){
    if(row[i] != j) return;
      }
    }
  }
 
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if(row[i] == j ) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void recursive(int i){
  if( i == N ){
    printBoard();
    return;
  }
 
  int j;
 
  for( j = 0 ; j < N ; j++ ){
    if( NOT_FREE == col[j] || NOT_FREE == dpos[i+j] || NOT_FREE == dneg[i-j+N-1]) continue;
 
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
 
    recursive(i+1);
 
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}
#include <algorithm>
#include <cmath>
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  const int k = rint();
  int rf[8] = {}, p[8 - k];
  bool cf[8] = {};
  dotimes(i, k) {
    int r = rint();
    int c = rint();
    rf[r] = c + 1;
    cf[c] = true;
  }
  for (int i = 0, j = 0, c = 0; i < 8; i++)
    if (!rf[i]) {
      while (cf[c])
        c++;
      p[j++] = ++c;
    }
  int a[8];
  for (;; next_permutation(p, p + 8 - k)) {
    for (int i = 0, j = 0; i < 8; i++)
      a[i] = rf[i] ? rf[i] : p[j++];
    dotimes(i, 8)
      dotimes(j, i)
        if (abs(a[j] - a[i]) == abs(j - i))
          goto failed;
    break;
  failed:
    ;
  }
  dotimes(i, 8) {
    dotimes(j, 8)
      putchar(a[i] == j + 1 ? 'Q' : '.');
    putchar('\n');
  }
  return 0;
}

