#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
   int k;
   cin >> k;
   vector<string> data(8,"........");
   vector<int> perm(8);
   rep(i,8) perm[i] = i;
   vector<int> x(k), y(k);
   rep(i,k) {
      int X, Y;
      cin >> X >> Y;
      x[i] = X;
      y[i] = Y;
   }
   do {
      bool ok = true;
      rep(i,k) {
         if (perm[y[i]] != x[i]) ok = false;
      }
      if (ok) {
         bool ans = true;
         rep(i,7) {
            for (int j = 1; i+j < 8; j++) {
               if (perm[i] + j == perm[i+j]) ans = false;
               if (perm[i] - j == perm[i+j]) ans = false;
            }
         }
         if (ans) {
            rep(i,8) {
               data[perm[i]][i] = 'Q';
            }
            rep(i,8) {
               rep(j,8) {
                  cout << data[i][j];
               }
               cout << endl;
            }
            return 0;
         }
      }
   } while(next_permutation(perm.begin(),perm.end()));
}
