using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20190129_AOJ
{
    class ALDS1_13A
    {
        static int N = 8;
        static int[,] ans = null;
        static void Main(string[] args)
        {
            for (;;)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    break;
                }

                int k = int.Parse(line);
                int[,] board = new int[N, N];
                for (int i = 0; i < k; i++)
                {
                    int[] arr = ReadIntArr();
                    board = Put(board, arr[0], arr[1]);
                }

                Progress(board, N-k);

                PrintBoard(ans);
            }
        }

        static void PrintBoard(int[,] b)
        {
            for(int i=0;i<N;i++)
            {
                StringBuilder sb = new StringBuilder();
                for(int j=0;j<N;j++)
                {
                    if(b[i,j] == 2)
                    {
                        sb.Append("Q");
                    }
                    else
                    {
                        sb.Append(".");
                    }
                }

                Console.WriteLine(sb.ToString());
            }
        }

        static void Progress(int[,] b, int rest)
        {
            if(rest == 0 || ans != null)
            {
                ans = new int[N, N];
                Array.Copy(b, ans, b.Length);

                return;
            }

            for(int i=0;i<N;i++)
            {
                for(int j=0;j<N;j++)
                {
                    if(b[i,j] == 0)
                    {
                        int[,] newB = Put(b, i, j);
                        if(newB != null)
                        {
                            Progress(newB, rest - 1);

                            if (ans != null)
                            {
                                i = N;
                                j = N;
                            }
                        }

                    }
                }
            }
        }

        static private int[,] Put(int[,] b, int y, int x)
        {
            int[,] newB = new int[N, N];
            Array.Copy(b, newB, b.Length);
            newB[y, x] = 2;

            bool isValid = true;

            int i, j;
            // 上
            {
                i = y - 1;
                j = x;
                while (i >= 0)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i--;
                }
            }

            // 右上
            if (isValid)
            {
                i = y - 1;
                j = x + 1;
                while (i >= 0 && j < N)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i--;
                    j++;
                }
            }

            // 右
            if(isValid)
            {
                i = y;
                j = x + 1;
                while (j < N)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    j++;
                }
            }

            // 右下
            if (isValid)
            {
                i = y + 1;
                j = x + 1;
                while (i < N && j < N)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i++;
                    j++;
                }
            }

            // 下
            if (isValid)
            {
                i = y + 1;
                j = x;
                while (i < N)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i++;
                }
            }

            // 左下
            if (isValid)
            {
                i = y + 1;
                j = x - 1;
                while (i < N && j >= 0)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i++;
                    j--;
                }
            }

            // 左
            if (isValid)
            {
                i = y;
                j = x - 1;
                while (j >= 0)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    j--;
                }
            }

            // 左上
            if (isValid)
            {
                i = y - 1;
                j = x - 1;
                while (i >= 0 && j >= 0)
                {
                    if (!UpdateCell(newB, i, j))
                    {
                        break;
                    }
                    i--;
                    j--;
                }
            }

            if(isValid)
            {
                return newB;
            }
            else
            {
                return null;
            }
        }

        static bool UpdateCell(int[,] b, int y, int x)
        {
            bool rv = true;
            if(b[y,x] == 2)
            {
                rv = false;
            }
            else
            {
                b[y, x] = 1;
            }

            return rv;
        }

        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static int[] ReadIntArr(char dlm = ' ') { return Console.ReadLine().Split(dlm).Select(x => int.Parse(x)).ToArray(); }
        static double[] ReadDoubleArr(char dlm = ' ') { return Console.ReadLine().Split(dlm).Select(x => double.Parse(x)).ToArray(); }
        static string[] ReadStringArr(char dlm = ' ') { return Console.ReadLine().Split(dlm).ToArray(); }
    }
}



Measured memory_bytes: 20324