// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_13_A&lang=jp
// 入力は0から始まる r,c
#include <bits/stdc++.h>
using namespace std;
struct status {
  int num;
  int board[8][8];
};

int main(void) {
  stack<status> st;
  status a;
  for (int r = 0; r < 8; r++) {
    for (int c = 0; c < 8; c++) {
      a.board[r][c] = 0;
    }
  }

  int k, R, C;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> R >> C;
    a.board[R][C] = 1;
  }
  a.num = k;
  st.push(a);

  while (st.empty() == false) {
    status x;
    x = st.top();
    st.pop();
    if (x.num == 8) {
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(x.board[i][j]==1){cout << "Q";}
                else{cout << ".";}
            }
            cout << endl;
        }
      break;
    }

    int target_row = -1;
    for (int i = 0; i < 8; i++) {
      int num = x.board[i][0] + x.board[i][1] + x.board[i][2] + x.board[i][3] +
                x.board[i][4] + x.board[i][5] + x.board[i][6] + x.board[i][7];
      if (num == 0 && target_row == -1)
        target_row = i;
    }

    for (int k = 0; k < 8; k++) {
      status t;
      for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
          t.board[i][j] = x.board[i][j];
        }
      }
      t.board[target_row][k] = 1;
      //ここでテスト　合格したら stにpush
      int enable=1;
      for(int j=0;j<8;j++){
        int num = t.board[0][j] + t.board[1][j] + t.board[2][j] + t.board[3][j] +
                  t.board[7][j] + t.board[6][j] + t.board[5][j] + t.board[4][j];
        if(num>1)enable=0;
      }
      if(t.board[6][0]+t.board[7][1]>1)enable=0;
      if(t.board[5][0]+t.board[6][1]+t.board[7][2]>1)enable=0;
      if(t.board[4][0]+t.board[5][1]+t.board[6][2]+t.board[7][3]>1)enable=0;
      if(t.board[3][0]+t.board[4][1]+t.board[5][2]+t.board[6][3]+t.board[7][4]>1)enable=0;
      if(t.board[2][0]+t.board[3][1]+t.board[4][2]+t.board[5][3]+t.board[6][4]+t.board[7][5]>1)enable=0;
      if(t.board[1][0]+t.board[2][1]+t.board[3][2]+t.board[4][3]+t.board[5][4]+t.board[6][5]+t.board[7][6]>1)enable=0;
      if(t.board[0][0]+t.board[1][1]+t.board[2][2]+t.board[3][3]+t.board[4][4]+t.board[5][5]+t.board[6][6]+t.board[7][7]>1)enable=0;
      if(t.board[0][1]+t.board[1][2]+t.board[2][3]+t.board[3][4]+t.board[4][5]+t.board[5][6]+t.board[6][7]>1)enable=0;
      if(t.board[0][2]+t.board[1][3]+t.board[2][4]+t.board[3][5]+t.board[4][6]+t.board[5][7]>1)enable=0;
      if(t.board[0][3]+t.board[1][4]+t.board[2][5]+t.board[3][6]+t.board[4][7]>1)enable=0;
      if(t.board[0][4]+t.board[1][5]+t.board[2][6]+t.board[3][7]>1)enable=0;
      if(t.board[0][5]+t.board[1][6]+t.board[2][7]>1)enable=0;
      if(t.board[0][6]+t.board[1][7]>1)enable=0;
      
      if(t.board[6][7]+t.board[7][6]>1)enable=0;
      if(t.board[5][7]+t.board[6][6]+t.board[7][5]>1)enable=0;
      if(t.board[4][7]+t.board[5][6]+t.board[6][5]+t.board[7][4]>1)enable=0;
      if(t.board[3][7]+t.board[4][6]+t.board[5][5]+t.board[6][4]+t.board[7][3]>1)enable=0;
      if(t.board[2][7]+t.board[3][6]+t.board[4][5]+t.board[5][4]+t.board[6][3]+t.board[7][2]>1)enable=0;
      if(t.board[1][7]+t.board[2][6]+t.board[3][5]+t.board[4][4]+t.board[5][3]+t.board[6][2]+t.board[7][1]>1)enable=0;
      if(t.board[0][7]+t.board[1][6]+t.board[2][5]+t.board[3][4]+t.board[4][3]+t.board[5][2]+t.board[6][1]+t.board[7][0]>1)enable=0;
      if(t.board[0][6]+t.board[1][5]+t.board[2][4]+t.board[3][3]+t.board[4][2]+t.board[5][1]+t.board[6][0]>1)enable=0;
      if(t.board[0][5]+t.board[1][4]+t.board[2][3]+t.board[3][2]+t.board[4][1]+t.board[5][0]>1)enable=0;
      if(t.board[0][4]+t.board[1][3]+t.board[2][2]+t.board[3][1]+t.board[4][0]>1)enable=0;
      if(t.board[0][3]+t.board[1][2]+t.board[2][1]+t.board[3][0]>1)enable=0;
      if(t.board[0][2]+t.board[1][1]+t.board[2][0]>1)enable=0;
      if(t.board[0][1]+t.board[1][0]>1)enable=0;
      
      if(enable==1){
          t.num=x.num+1;
          st.push(t);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3172