using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        class EQueens
        {
            struct pair
            {
                public long r, c;
                public pair(long r, long c) { this.r = r; this.c = c; }
            }
            const int MASU = 8;
            bool[] isrow;
            bool[] iscol;
            bool[] isdpos;
            bool[] isdneg;
            bool[] maeoki;
            int num = MASU;
            bool[,] ban;

            public EQueens()
            {
                isrow = new bool[MASU];
                iscol = new bool[MASU];
                isdpos = new bool[2 * MASU - 1];
                isdneg = new bool[2 * MASU - 1];
                maeoki = new bool[MASU];
                ban = new bool[MASU, MASU];
            }
            public void addpre(long row, long col)
            {
                --num;
                maeoki[row] = true;
                ban[row, col] = true;
                setQueen(row, col, true);
            }
            void setQueen(long row, long col, bool b)
            {
                isrow[row] = b;
                iscol[col] = b;
                isdpos[row + col] = b;
                isdneg[row - col + MASU - 1] = b;
            }
            bool isQueen(long row, long col)
            {
                return isrow[row] | iscol[col] | isdpos[row + col] | isdneg[row - col + MASU - 1];
                /*
                for (var i = 0; i < MASU; ++i)
                {
                    if (ban[row, i]) return true;
                    if (ban[i, col]) return true;
                }
                var min = Math.Min(row, col);
                var max = Math.Max(row, col);
                for (var o = 0; o < MASU - (max - min); ++o)
                    if (ban[row - min + o, col - min + o])
                        return true;
                min = Math.Min(row, MASU-1 - col);
                max = Math.Max(row, MASU-1 - col);
                for (var o = 0; o < MASU - (max - min); ++o)
                    if (ban[row - min + o, col + min - o])
                        return true;
                return false;
                */
            }
            Stack<pair> s;
            public bool[,] dfs()
            {
                for (var i = 0; i < MASU; ++i)
                {
                    s = new Stack<pair>();
                    if (dfs_(0, i)) break;
                }
                foreach (var k in s)
                    ban[k.r, k.c] = true;
                return ban;
            }
            bool dfs_(long row, long col)
            {
                if (MASU <= row) return true;
                if (maeoki[row]) return dfs_(row + 1, col);
                else
                {
                    if (isQueen(row, col))
                        return false;
                    setQueen(row, col, true);
                    s.Push(new pair(row, col));
                    if (num <= s.Count) return true;
                    for(var i=0;i<MASU;++i)
                    {
                        dfs_(row + 1, i);
                        if (num <= s.Count)
                            return true;
                    }
                    var t = s.Pop();
                    setQueen(t.r, t.c, false);
                }
                return false;
            }
        }
        static void Main(string[] args)
        {
            var k = Sarray()[0];
            var eq = new EQueens();
            for (var i = 0; i < k; ++i)
            {
                var t = Sarray();
                eq.addpre(t[0], t[1]);
            }
            var ban = eq.dfs();
            for (var i = 0; i < 8; ++i)
            {
                for (var j = 0; j < 8; ++j)
                    Write($"{(ban[i, j] ? "Q" : ".")}");
                WriteLine();
            }
        }
    }
}


Measured memory_bytes: 18880