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

namespace ALDS1_13_A_8_Queens_Problem
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int inputCount = int.Parse (Console.ReadLine ());

			Point[] points = new Point[inputCount];

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] point = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				points[lp] = new Point (point[0], point[1]);
			}

			//process
			Search queen = new Search (8, points);
			queen.SearchPattern (0, points);
		}
	}

	class Search
	{
		public Search ( int length, Point[] points )
		{
			this.Length = length;
			this.EndFlag = false;

			this.RowRange = Enumerable.Repeat (Safe, this.Length).ToArray ();
			this.ColRange = Enumerable.Repeat (Safe, this.Length).ToArray ();
			this.RightSlantRange = Enumerable.Repeat (Safe, this.Length * 2 - 1).ToArray ();
			this.LeftSlantRange = Enumerable.Repeat (Safe, this.Length * 2 - 1).ToArray ();

			this.PointCase = new Stack<Point> (this.Length);

			//入力値に応じてクイーンを配置する
			foreach (var item in points)
			{
				this.RowRange[item.Row] = Warning;
				this.ColRange[item.Col] = Warning;
				this.RightSlantRange[RightSlantIndex (item.Row, item.Col)] = Warning;
				this.LeftSlantRange[LeftSlantIndex (item.Row, item.Col)] = Warning;

				this.PointCase.Push (item);
			}
		}

		private int[] RowRange { set; get; }
		private int[] ColRange { set; get; }
		private int[] RightSlantRange { set; get; }
		private int[] LeftSlantRange { set; get; }
		private Stack<Point> PointCase { set; get; }

		private int Length { set; get; }
		private bool EndFlag { set; get; }

		private const int Warning = 1;
		private const int Safe = 0;

		private const char Queen = 'Q';
		private const char Nothing = '.';

		public void SearchPattern ( int row, Point[] putPoint )
		{
			//Length個置き終わったら
			if (row == Length)
			{
				Print ();
				EndFlag = true;
				return;
			}

			//入力値で既に配置していたら
			if (putPoint.Any (point => point.Row == row))
			{
				SearchPattern (row + 1, putPoint);
			}

			for (int col = 0; col < Length; col++)
			{
				int index1 = RightSlantIndex (row, col);
				int index2 = LeftSlantIndex (row, col);

				if (EndFlag)
				{
					break;
				}

				//クイーンが配置できるのであれば
				if (ColRange[col] == Safe &&
					RightSlantRange[index1] == Safe &&
					LeftSlantRange[index2] == Safe)
				{
					//配置する
					RowRange[row] = ColRange[col] = RightSlantRange[index1] = LeftSlantRange[index2] = Warning;
					PointCase.Push (new Point (row, col));

					//次の行に進む
					SearchPattern (row + 1, putPoint);

					//配置を取り消す
					RowRange[row] = ColRange[col] = RightSlantRange[index1] = LeftSlantRange[index2] = Safe;
					PointCase.Pop ();
				}
			}
		}

		public void Print ()
		{
			StringBuilder output = new StringBuilder (Length * Length);
			Point[] points = PointCase.ToArray ();
			Array.Sort (points, ( item1, item2 ) => item1.Row - item2.Row);

			foreach (var item in points)
			{
				char[] state = Enumerable.Repeat (Nothing, Length).ToArray ();
				state[item.Col] = Queen;
				output.Append (state);
				output.AppendLine ();
			}

			Console.Write (output);
		}

		private int RightSlantIndex ( int row, int col )
		{
			return row + col;
		}
		private int LeftSlantIndex ( int row, int col )
		{
			return row - col + Length - 1;
		}
	}

	class Point
	{
		public Point ( int row, int col )
		{
			this.Row = row;
			this.Col = col;
		}

		public int Row { private set; get; }
		public int Col { private set; get; }
	}
}



Measured memory_bytes: 10436