using System;
using System.Collections.Generic;
using System.Linq;

namespace ALDS1_13_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());

            List<int> firstx = new List<int>();
            List<int> firsty = new List<int>();
            for (int i = 0; i < 8; i++)
            {
                firstx.Add(i);
                firsty.Add(i);
            }

            int[,] ans = new int[8, 8];
            for (int i = 0; i < k; i++)
            {
                var input = ReadInt();
                ans[input[0], input[1]] = 1;
                firstx.Remove(input[0]);
                firsty.Remove(input[1]);
            }

            var searchX = GetPermutation(firstx).ToArray();
            var searchY = GetPermutation(firsty).ToArray();
            var max = searchX.GetLength(0);

            for (int i = 0; i < max; i++)
            {
                bool ok = false;
                for (int j = 0; j < max; j++)
                {
                    int[,] temp = new int[8, 8];
                    Array.Copy(ans, temp, 64);

                    for (int m = 0; m < 8 - k; m++)
                    {
                        int indexx = searchX[i][m];
                        int indexy = searchY[j][m];
                        temp[indexx, indexy] = 1;
                    }

                    ok = CheckMap(temp);
                    if (ok)
                    {
                        ans = temp;
                        break;
                    }
                }
                if (ok) break;
            }

            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (ans[i, j] == 1) Console.Write("Q");
                    else Console.Write(".");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }


        static bool CheckMap(int[,] map)
        {
            int[] sums = new int[15];
            int[] sums2 = new int[15];
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    sums[(i + j)] += map[i, j];
                    sums2[(j - i) + 7] += map[i, j];
                }
            }

            int sum = sums.Where(s => s > 1).Count();
            int sum2 = sums2.Where(s => s > 1).Count();
            if (sum != 0 || sum2 != 0) return false;
            else return true;
        }

        /// <summary>
        /// 順列組み合わせ
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="collection"></param>
        /// <returns></returns>
        public static IEnumerable<T[]> GetPermutation<T>(IEnumerable<T> collection)
        {
            if (collection.Count() == 1)
            {
                yield return new T[] { collection.First() };
            }

            foreach (var item in collection)
            {
                var selected = new T[] { item };
                var unused = collection.Except(selected);

                foreach (var rightside in GetPermutation(unused))
                {
                    yield return selected.Concat(rightside).ToArray();
                }
            }
        }


        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 24748