#include <bits/stdc++.h>
using namespace std;

static const int BOARD_SIZE = 8;	// チェスボードの大きさ（縦横で同じ）

/* -------------------------------------------------------------------------- */
/* QueenCommand クラス                                                        */
/* -------------------------------------------------------------------------- */
class QueenCommand
{
public:
	QueenCommand();
	
	bool contains(int r, int c);
	void put_on(int r, int c);
	void take_off(int r, int c);

	int to_dpos_idx(int r, int c)
	{
		return r + c;
	}

	int to_dneg_idx(int r, int c)
	{
		return r + (BOARD_SIZE - 1 - c);
	}

private:
	/* 横, 右斜め、左斜めのクイーンの利き (true で利きがある) */
	bool column[BOARD_SIZE];		/* 横 */
	bool dpos[2 * BOARD_SIZE - 1];	/* 左下～右上に向かう方向の斜め（傾きが正なので pos） */
	bool dneg[2 * BOARD_SIZE - 1];	/* 左上～右下に向かう方向の斜め（傾きが負なので neg） */
};

/* -------------------------------------------------------------------------- */

QueenCommand::QueenCommand()
{
	for(int i = 0; i < BOARD_SIZE; i++)
	{
		column[i] = false;
	}
	for(int i = 0; i < 2 * BOARD_SIZE - 1; i++)
	{
		dpos[i] = dneg[i] = false;
	}
}

bool QueenCommand::contains(int r, int c)
{
	int dpos_idx = to_dpos_idx(r, c);
	int dneg_idx = to_dneg_idx(r, c);
	return ( column[c] || dpos[dpos_idx] || dneg[dneg_idx]);
}

void QueenCommand::put_on(int r, int c)
{
	int dpos_idx = to_dpos_idx(r, c);
	int dneg_idx = to_dneg_idx(r, c);
	column[c] = dpos[dpos_idx] = dneg[dneg_idx] = true;
}

void QueenCommand::take_off(int r, int c)
{
	int dpos_idx = to_dpos_idx(r, c);
	int dneg_idx = to_dneg_idx(r, c);
	column[c] = dpos[dpos_idx] = dneg[dneg_idx] = false;
}

/* -------------------------------------------------------------------------- */
/* Queen8 クラス                                                              */
/* -------------------------------------------------------------------------- */
class Queen8
{
public:
	Queen8();
	
	void solve();
	void set_initial_pos(int row, int column);
	void print();

private:
	/* メンバ関数 */
	void solve_recursive(int row);
	bool put_on(int row, int column);
	void take_off(int row, int column);

	/* メンバ変数 */
	const int FREE;
	
	QueenCommand     command;
	map<int, int>    pos;			// key=row, value=column
	map<int, int>    initial_pos;
	map<int, int>    answer;		// key=row, value=column
	bool found;
};

/* -------------------------------------------------------------------------- */
Queen8::Queen8() : FREE(-1)
{
	found = false;
	for(int i = 0; i < BOARD_SIZE; i++)
	{
		pos[i]         = FREE;
		initial_pos[i] = FREE;
	}
}

void Queen8::solve()
{
	found = false;
	answer.clear();
	solve_recursive(0);
}

void Queen8::set_initial_pos(int row, int column)
{
	initial_pos[row] = column;
}

void Queen8::print()
{
	if(found)
	{
		for(int r = 0; r < BOARD_SIZE; r++)
		{
			int queen_column = answer[r];
			for(int c = 0; c < BOARD_SIZE; c++)
			{
				cout << ((queen_column == c) ? 'Q' : '.');
			}
			cout << endl;
		}
	}
}

void Queen8::solve_recursive(int row)
{
	if( found )
	{
		/* 既に探索完了済 */
		return;
	}

	if(row == BOARD_SIZE)	
	{
		/* 全列置いたので探索完了 */
		answer = pos;
		found  = true;
		return;
	}

	for(int column = 0; column < BOARD_SIZE; column++)	/* 全列総当りで */
	{
		bool put_result = put_on(row, column);			/* クイーンを置いてみる */
		if(put_result)									/* 置けたら */
		{
			solve_recursive(row + 1);					/* 次の行のQueenを置く */
			take_off(row, column);						/* 置いたQueenを戻す */
		}
	}
	
	return;
}

bool Queen8::put_on(int row, int column)
{
	/* 他の駒が利いている */
	if(command.contains(row, column))
	{
		return false;
	}

	/* 最初に置いたクイーンにかぶる */
	if(initial_pos[row] != FREE && initial_pos[row] != column)
	{
		return false;
	}

	/* 置く */
	pos[row] = column;
	command.put_on(row, column);

	return true;
}

void Queen8::take_off(int row, int column)
{
	pos[row] = FREE;
	command.take_off(row, column);
}

/* -------------------------------------------------------------------------- */
/* It's main !!!                                                              */
/* -------------------------------------------------------------------------- */

int main()
{
	Queen8 q8;

	int k, r, c;
	cin >> k;
	
	for(int i = 0; i < k; i++)
	{
		cin >> r >> c;
		q8.set_initial_pos(r, c);
	}
	
	q8.solve();
	q8.print();
	
	return 0;
}




Measured memory_bytes: 3096