#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#define MAX 10000
#define INFTY 1<<30 // 2^30
#define N 8
using namespace std;
typedef long long llong;
static const int NIL = -1;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

static const int NOT_FREE = 0;
static const int FREE = 1;
static const int FIXED = 2;

bool X[N][N];
vector<pair<int, int> > ans;

void init()
{
  for(int i = 0; i < N; i++)
    for(int j = 0; j < N; j++)
      X[i][j] = false;
}

bool can_pos(int x, int y)
{
  for(int i = 0; i < ans.size(); i++)
  {
    int tx = ans[i].first;
    int ty = ans[i].second;
    if(x == tx) return false;
    if(y == ty) return false;
    if((x-tx)*(x-tx) == (y-ty)*(y-ty)) return false;
  }
  return true;
}

void printBoard()
{
  for(int i = 0; i < ans.size(); i++)
    X[ans[i].first][ans[i].second] = true;
  for(int i = 0; i < N; i++)
  {
    for(int j = 0; j < N; j++)
      cout << (X[i][j] ? "Q" : ".");
    cout << endl;
  }
}

bool recursive(int p)
{
  for(; p < N * N; p++)
  {
    int i = p%N;
    int j = p/N;
    if(!(can_pos(i,j))) continue;
    pair<int, int>tmp = make_pair(i, j);
    ans.push_back(tmp);
    if(!recursive((j+1)*N)) ans.pop_back();
  }
  if(ans.size() == N) return true;
  return false;
}

int main()
{
  init();
  int k, r, c; cin >> k;
  for(int i = 0; i < k; i++)
  {
    cin >> r >> c;
    pair<int, int> tmp = make_pair(r, c);
    ans.push_back(tmp);
  }
  if(recursive(0)) printBoard();
  return 0;
}
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

const char Q = 'Q';
const char _ = '.';

char board[8][9] = {
    "........",
    "........",
    "........",
    "........",
    "........",
    "........",
    "........",
    "........",
};

int n;
bool pre_x[8], pre_y[8];

inline bool check(int x, int y) {
    int p = x, q = y;
    while (--p >= 0 && --q >= 0) {  // upper left 
        if (board[q][p] == Q) return false;
    }

    p = x; q = y;
    while (++p < 8 && --q >= 0) {   // upper right 
        if (board[q][p] == Q) return false;
    }

    p = x; q = y;
    while (++p < 8 && ++q < 8) {    // lower right 
        if (board[q][p] == Q) return false;
    }

    p = x; q = y;
    while (--p >= 0 && ++q < 8) {   // lower left 
        if (board[q][p] == Q) return false;
    }

    return true;
}

bool solve(int row) {
    if (row == 8)
        return true;
    if (pre_y[row] && solve(row + 1)) {
        return true;
    }
    else {
        for (int i = 0; i < 8; ++i) {
            if (!pre_x[i] && check(i, row)) {
                board[row][i] = Q;
                pre_x[i] = true;
                if (solve(row + 1)) {
                    return true;
                }
                else {
                    board[row][i] = _;
                    pre_x[i] = false;
                }
            }
        }
    }
    return false;
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0, x, y; i < n; ++i) {
        scanf("%d %d", &y, &x);
        board[y][x] = Q;
        pre_y[y] = pre_x[x] = true;
    }

    solve(0);

    for (int i = 0; i < 8; ++i) {
        printf("%s\n", board[i]);
    }

    return 0;
}