using System;
using System.Linq;
using System.Collections.Generic;
class EightQueen
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var rc = Enumerable.Range(0, n)
			.Select(_ => Console.ReadLine());
		
		var board = new Board(rc);
        board.InitAttackedArea();
        
        var resultBoard = board.Explore();
        
        resultBoard.Nodes.ForEach(row => 
            Console.WriteLine(string.Join("", row.Select(x => x.QueenExists ? "Q" : ".").ToArray())));
	}
}

public class Board
{
    public Node[][] Nodes{ get; set; }
 	const int Size = 8;
   
    public Board() {}
	public Board(IEnumerable<string> rc)
	{
		var queens = rc.Select(x => x.Split())
			.Select(x => new 
            { 
                Row = int.Parse(x[0]), 
                Column = int.Parse(x[1]) 
            })
			.ToArray();
		
		Nodes = Enumerable.Range(0, Size)
			.Select(row => Enumerable
				.Range(0, Size)
				.Select(column => new Node
                { 
                    QueenExists = queens.Any(x => x.Row == row && x.Column == column) 
                })
                .ToArray())
            .ToArray();
	}
    
    // ?????????????????¢???????????¨?????¢?¨????
    public void InitAttackedArea()
    {
        Nodes.ForEach((x, row) => x.ForEach((node, column) =>
        {
            ApplyAttackedArea(row, column);
        }));
    }
    
    public void ApplyAttackedArea(int row, int column)
    {
        var node = Nodes[row][column];
        if (!node.QueenExists)
            return; 
        
        // row
        Nodes[row].ForEach(x =>             
        {
            x.IsAttackedArea = true;
        });
        
        // column
        Nodes.ForEach(rows => 
        {
            rows[column].IsAttackedArea = true;
        });
        
        // from left top to right bottom
        for (int r = row - Size, c = column - Size; r < Size && c < Size; r++, c++)
        {
            // ????????????????????????????????????????§??????????????????§??????????????????????????´???????????§???????????????
            if (r >= Size || c >= Size || r < 0 || c < 0)
                continue;
            
            Nodes[r][c].IsAttackedArea = true;
        }
        
        // from right top to left bottom
        for (int r = row - Size, c = column + Size; r < Size && c >= 0; r++, c--)
        {
            // ????????????????????????????????????????§??????????????????§??????????????????????????´???????????§???????????????
            if (r >= Size || c >= Size || r < 0 || c < 0)
                continue;
            
            Nodes[r][c].IsAttackedArea = true;
        }
    }
    
    public Board Clone()
    {  
        return new Board
        { 
            Nodes = Nodes.Select(x => 
                x.Select(y => new Node
                    { 
                        IsAttackedArea = y.IsAttackedArea, 
                        QueenExists = y.QueenExists 
                    })
                    .ToArray())
                .ToArray()
        };
    }
   
    public Board Explore()
    {
        return Enumerable.Range(0, Size)
            .Where(row => Nodes[row].All(x => !x.QueenExists))
            .Select(row => Enumerable.Range(0, Size)
                .Select(column => Explore(this, row, column))
                .FirstOrDefault(x => x != null))
            .DefaultIfEmpty(this)
            .FirstOrDefault();
    }
    
    private static Board Explore(Board board, int r, int c)
    {
        if (board.Nodes[r][c].IsAttackedArea)
            return null;
        
        // check???????????????
        board.Nodes[r][c].IsAttackedArea = true;
        
        // ?????????????????£?????¨?????¨?????????????????????????????????????????????
        var b = board.Clone();
        
        b.Nodes[r][c].QueenExists = true;
        
        // ???????¨??????????queen?????¢???????????¨?????¢?¨????
        b.ApplyAttackedArea(r, c);
        
        var nextRow = Enumerable.Range(r + 1, Size - (r + 1))
            .Where(x => b.Nodes[x].All(node => !node.QueenExists))
            .DefaultIfEmpty(Size)
            .Min();
        
        // ?¬????????????£????????¢?´¢??????????????????board???????????§??°??£??????
        if (nextRow >= Size)
            return b;
        
        return Enumerable.Range(0, Size)
            .Where(x => !b.Nodes[nextRow][x].IsAttackedArea)
            .Select(x => Explore(b, nextRow, x))
            .FirstOrDefault(x => x != null);
    }
}

public class Node
{
    public bool QueenExists { get; set; }
    public bool IsAttackedArea { get; set; }
}


// ??????????????¨?????????????????????????????§???
public static class MyExtensions
{
	public static void ForEach<T>(this IEnumerable<T> e, Action<T> action)
	{
		foreach (var element in e) action(element);
	}
	
	public static void ForEach<T>(this IEnumerable<T> e, Action<T, int> action)
	{
		var i = 0;
		foreach (var element in e) action(element, i++);
	}
}

Measured memory_bytes: 14100