#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

set<pair<int, int>> erase_pos(pair<int, int> rc, set<pair<int, int>> place_left)
{
  place_left.erase(rc);
  int r, c;
  r = rc.first;
  c = rc.second;
  for (int i = 0; i < 8; ++i)
  {
    place_left.erase({r, i});
    place_left.erase({i, c});
  }
  vector<int> inc_dec = {-1, 1};
  for (int i: inc_dec)
  {
    for (int j: inc_dec)
    {
      int now_r, now_c;
      now_r = r;
      now_c = c;
      while (true)
      {
        now_r += i;
        now_c += j;
        if (now_r == -1 || now_r == 8 || now_c == -1 || now_c == 8)
        {
          break;
        }
        place_left.erase({now_r, now_c});
      }
    }
  }
  return place_left;
}

int main()
{
  set<pair<int, int>> place_left;
  set<pair<int, int>> ans;
  for (int i = 0; i < 8; ++i)
  {
    for (int j = 0; j < 8; ++j)
    {
      place_left.insert({i, j});
    }
  }
  int k;
  cin >> k;
  int r, c;
  for (int i = 0; i < k; ++i)
  {
    cin >> r >> c;
    place_left = erase_pos({r, c}, place_left);
    // for (int i = 0; i < 8; ++i)
    // {
    //   for (int j = 0; j < 8; ++j)
    //   {
    //     if (place_left.find({i, j}) != place_left.end())
    //     {
    //       cout << '.';
    //     }
    //     else
    //     {
    //       cout << 'Q';
    //     }
    //   }
    //   cout << endl;
    // }
    // cout << endl;
    ans.insert({r, c});
  }

  bool end = false;
  for (auto itr1 = place_left.begin(); itr1 != place_left.end(); ++itr1)
  {
    pair<int, int> n1 = *itr1;
    set<pair<int, int>> p1_left = erase_pos(n1, place_left);
    if (place_left.size() == 1 && k == 7)
    {
      ans.insert(n1);
      end = true;
      break;
    }
    for (auto itr2 = p1_left.begin(); itr2 != p1_left.end(); ++itr2)
    {
      pair<int, int> n2 = *itr2;
      set<pair<int, int>> p2_left = erase_pos(n2, p1_left);
      if (p1_left.size() == 1 && k == 6)
      {
        ans.insert(n1);
        ans.insert(n2);
        end = true;
        break;
      }
      for (auto itr3 = p2_left.begin(); itr3 != p2_left.end(); ++itr3)
      {
        pair<int, int> n3 = *itr3;
        set<pair<int, int>> p3_left = erase_pos(n3, p2_left);
        if (p2_left.size() == 1 && k == 5)
        {
          ans.insert(n1);
          ans.insert(n2);
          ans.insert(n3);
          end = true;
          break;
        }
        for (auto itr4 = p3_left.begin(); itr4 != p3_left.end(); ++itr4)
        {
          pair<int, int> n4 = *itr4;
          set<pair<int, int>> p4_left = erase_pos(n4, p3_left);
          if (p3_left.size() == 1 && k == 4)
          {
            ans.insert(n1);
            ans.insert(n2);
            ans.insert(n3);
            ans.insert(n4);
            end = true;
            break;
          }
          for (auto itr5 = p4_left.begin(); itr5 != p4_left.end(); ++itr5)
          {
            pair<int, int> n5 = *itr5;
            set<pair<int, int>> p5_left = erase_pos(n5, p4_left);
            if (p4_left.size() == 1 && k == 3)
            {
              ans.insert(n1);
              ans.insert(n2);
              ans.insert(n3);
              ans.insert(n4);
              ans.insert(n5);
              end = true;
              break;
            }
            for (auto itr6 = p5_left.begin(); itr6 != p5_left.end(); ++itr6)
            {
              pair<int, int> n6 = *itr6;
              set<pair<int, int>> p6_left = erase_pos(n6, p5_left);
              if (p5_left.size() == 1 && k == 2)
              {
                ans.insert(n1);
                ans.insert(n2);
                ans.insert(n3);
                ans.insert(n4);
                ans.insert(n5);
                ans.insert(n6);
                end = true;
                break;
              }
              for (auto itr7 = p6_left.begin(); itr7 != p6_left.end(); ++itr7)
              {
                pair<int, int> n7 = *itr7;
                set<pair<int, int>> p7_left = erase_pos(n7, p6_left);
                if (p6_left.size() == 1 && k == 1)
                {
                  ans.insert(n1);
                  ans.insert(n2);
                  ans.insert(n3);
                  ans.insert(n4);
                  ans.insert(n5);
                  ans.insert(n6);
                  ans.insert(n7);
                  end = true;
                  break;
                }
              }
              if (end)
              {
                break;
              }
            }
            if (end)
            {
              break;
            }
          }
          if (end)
          {
            break;
          }
        }
        if (end)
        {
          break;
        }
      }
      if (end)
      {
        break;
      }
    }
    if (end)
    {
      break;
    }
  }


  for (int i = 0; i < 8; ++i)
  {
    for (int j = 0; j < 8; ++j)
    {
      if (ans.find({i, j}) == ans.end())
      {
        cout << '.';
      }
      else
      {
        cout << 'Q';
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 3128