#include <iostream>
#include <stack>
#include <vector>
#include <list>
#include <queue>

using namespace std;

template<typename T>
void PrintArray(const T* pArray, int size)
{
	for (int i = 0; i < size; ++i)
		cout << pArray[i] << (i != size - 1 ? " " : "\n");
}

#define CHESS_SIZE 8
char g_Chess[CHESS_SIZE][CHESS_SIZE];
bool g_Horizontal[CHESS_SIZE];
bool g_Vertical[CHESS_SIZE];
bool g_Dig[2 * CHESS_SIZE - 1];
bool g_RevertDig[2 * CHESS_SIZE - 1];

bool IsHorizontalVlaid(int col)
{
	return !g_Horizontal[col];
}

bool IsVerticalValid(int row)
{
	return !g_Vertical[row];
}

bool IsDiaValid(int col, int row)
{
	return !g_Dig[col + row];
}

bool IsRevertDiaValid(int col, int row)
{
	return !g_RevertDig[col - row + CHESS_SIZE - 1];
}

void SetHorizontal(int col, bool value)
{
	g_Horizontal[col] = value;
}

void SetVertical(int row, bool value)
{
	g_Vertical[row] = value;
}

void SetDia(int col, int row, bool value)
{
	g_Dig[col + row] = value;
}

void SetRevertDia(int col, int row, bool value)
{
	g_RevertDig[col - row + CHESS_SIZE - 1] = value;
}

void DFS(int col)
{
	if (col >= CHESS_SIZE)
	{
		for (int col = 0; col < CHESS_SIZE; ++col)
		{
			for (int row = 0; row < CHESS_SIZE; ++row)
			{
				cout << g_Chess[col][row] << " ";
			}
			cout << endl;
		}
		cout << endl;
		return;
	}

	for (int row = 0; row < CHESS_SIZE; ++row)
	{
		if (IsHorizontalVlaid(col) && IsVerticalValid(row)
			&& IsDiaValid(col, row)
			&& IsRevertDiaValid(col, row)
			)
		{
			g_Chess[col][row] = 'Q';
			SetHorizontal(col, true);
			SetVertical(row, true);
			SetDia(col, row, true);
			SetRevertDia(col, row, true);
			DFS(col + 1);
			g_Chess[col][row] = '.';
			SetHorizontal(col, false);
			SetVertical(row, false);
			SetDia(col, row, false);
			SetRevertDia(col, row, false);
		}
	}
}

void InitChess()
{
	for (int col = 0; col < CHESS_SIZE; ++col)
	{
		SetHorizontal(col, false);
		SetVertical(col, false);
		for (int row = 0; row < CHESS_SIZE; ++row)
		{
			SetDia(col, row, false);
			SetRevertDia(col, row, false);
			g_Chess[col][row] = '.';
		}
	}
}

void Queue()
{
	DFS(0);
}

int GetQueueRow(int col)
{
	for (int row = 0; row < CHESS_SIZE; ++row)
	{
		if (g_Chess[col][row] == 'Q')
			return row;
	}

	return -1;
}

void ALDS1_13_A(int col)
{
	if (col >= CHESS_SIZE)
	{
		for (int col = 0; col < CHESS_SIZE; ++col)
		{
			for (int row = 0; row < CHESS_SIZE; ++row)
			{
				cout << g_Chess[col][row];
			}
			cout << endl;
		}
		return;
	}

	int result = GetQueueRow(col);
	if (-1 == result)
	{
		for (int row = 0; row < CHESS_SIZE; ++row)
		{
			if (IsHorizontalVlaid(col) && IsVerticalValid(row)
				&& IsDiaValid(col, row)
				&& IsRevertDiaValid(col, row)
				)
			{
				g_Chess[col][row] = 'Q';
				SetHorizontal(col, true);
				SetVertical(row, true);
				SetDia(col, row, true);
				SetRevertDia(col, row, true);
				ALDS1_13_A(col + 1);
				g_Chess[col][row] = '.';
				SetHorizontal(col, false);
				SetVertical(row, false);
				SetDia(col, row, false);
				SetRevertDia(col, row, false);
			}
		}
	}
	else
	{
		ALDS1_13_A(col + 1);
	}
}

int main()
{
	InitChess();

	int n; 
	cin >> n;
	int col, row;
	for (int i = 0; i < n; ++i)
	{
		cin >> col >> row;
		g_Chess[col][row] = 'Q';
		SetHorizontal(col, true);
		SetVertical(row, true);
		SetDia(col, row, true);
		SetRevertDia(col, row, true);
	}

	//Queue();
	ALDS1_13_A(0);

	return 0;
}


Measured memory_bytes: 3100