using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_13A
{
    public class Program
    {
        const int Size = 8;
        readonly int[,] attack = new int[Size + 2, Size + 2];
        readonly bool[,] queen = new bool[Size + 2, Size + 2];
        readonly List<string> ansList = new List<string>();

        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var K = ss.Next(int.Parse);
            for (var i = 0; i < K; i++)
            {
                var R = ss.Next(int.Parse) + 1;
                var C = ss.Next(int.Parse) + 1;
                Put(C, R);
            }

            DFS(K, 0);
            foreach (var ans in ansList) sw.Write(ans);
            //---------------------------------
        }

        string MakeAnser()
        {
            var sb = new StringBuilder();
            for (var i = 1; i <= Size; i++)
            {
                for (var j = 1; j <= Size; j++) sb.Append(queen[i, j] ? "Q" : ".");
                sb.AppendLine();
            }
            return sb.ToString();
        }

        void DFS(int count, int pos)
        {
            if (count == Size)
            {
                ansList.Add(MakeAnser());
                return;
            }

            if (pos >= Size * Size) return;

            for (var i = pos; i < Size * Size; i++)
            {
                var x = i % Size + 1;
                var y = i / Size + 1;
                if (!CanPut(x, y)) continue;

                Put(x, y);
                DFS(count + 1, i + 1);
                Remove(x, y);
            }
        }

        bool CanPut(int x, int y)
        {
            return attack[y, x] == 0 && !queen[y, x];
        }

        void Put(int x, int y)
        {
            queen[y, x] = true;
            ChangeAttack(x, y, 1);
        }

        void Remove(int x, int y)
        {
            queen[y, x] = false;
            ChangeAttack(x, y, -1);
        }

        void ChangeAttack(int x, int y, int atk)
        {
            for (var i = 1; i <= Size; i++)
            for (var j = 1; j <= Size; j++)
            {
                if (x == j || y == i || Math.Abs(x - j) == Math.Abs(y - i)) attack[i, j] += atk;
            }
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}


Measured memory_bytes: 18448