#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

#define SPACE (0)
#define QUEEN (1)
#define KIKI  (2)

class ChessBoard{
private:
	std::vector<char> cur_board_;
	std::vector<int> is_covered_board_;
	std::vector<std::pair<int, int> > directions_;

public:
	ChessBoard(){
		cur_board_.resize(64, '.');
		is_covered_board_.resize(64, SPACE);

		directions_.push_back(std::pair<int, int>(1, 0));
		directions_.push_back(std::pair<int, int>(-1, 0));
		directions_.push_back(std::pair<int, int>(0, 1));
		directions_.push_back(std::pair<int, int>(0, -1));
		directions_.push_back(std::pair<int, int>(1, 1));
		directions_.push_back(std::pair<int, int>(1, -1));
		directions_.push_back(std::pair<int, int>(-1, 1));
		directions_.push_back(std::pair<int, int>(-1, -1));
		return;
	}
	~ChessBoard(){
		return;
	}

	bool can_set(int x, int y){
		if(is_covered_board_[y * 8 + x] != SPACE){
			return false;
		}

		bool settable = true;


		for(int i = 0; i < directions_.size(); i++){
			int xx = x;
			int yy = y;

			for(;;){
				xx += directions_[i].first;
				yy += directions_[i].second;

				if(xx < 0 || xx >= 8 || yy < 0 || yy >= 8){
					break;
				}

				if(is_covered_board_[yy * 8 + xx] == QUEEN){
					settable = false;
					i = directions_.size();
					break;
				}
			}
		}

		return settable;
	}

	std::vector<std::pair<int, int> > make_candidates(){
		std::vector<std::pair<int, int> > candidates;

		for(int y = 0; y < 8; y++){
			for(int x = 0; x < 8; x++){
				if(can_set(x, y)){
					candidates.push_back(std::pair<int, int>(x, y));
				}
			}
		}

		return candidates;
	}

	void set(int x, int y){
		cur_board_[y * 8 + x] = 'Q';
		is_covered_board_[y * 8 + x] = QUEEN;
		for(int i = 0; i < directions_.size(); i++){
			int xx = x;
			int yy = y;
			for(;;){
				xx += directions_[i].first;
				yy += directions_[i].second;

				if(xx < 0 || xx >= 8 || yy < 0 || yy >= 8){
					break;
				}
				is_covered_board_[yy * 8 + xx] = KIKI;
			}
		}
	}

	void print_board(){
		for(int y = 0; y < 8; y++){
			int offset = y * 8;
			for(int x = 0; x < 8; x++){
				std::cout << cur_board_[offset + x];
			}
			std::cout << std::endl;
		}
		//std::cout << std::endl;
	}

	void print_is_covered_board(){
		for(int y = 0; y < 8; y++){
			int offset = y * 8;
			for(int x = 0; x < 8; x++){
				std::cout << is_covered_board_[offset + x];
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
};

ChessBoard result;

void dfs(ChessBoard chess_board, int k){
	if(k == 8){
		result = chess_board;
	}
	else{
		std::vector<std::pair<int, int> > candidates = chess_board.make_candidates();
		for(int i = 0; i < candidates.size(); i++){
			ChessBoard tmp = chess_board;
			tmp.set(candidates[i].first, candidates[i].second);
			dfs(tmp, k + 1);
		}
	}
	return;
}

int main(int argc, char **argv){
	int k, r, c;
	ChessBoard chess_board;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> k;
#else
	std::cin >> k;
#endif

	for(int i = 0; i < k; i++){
#if INPUT_FROM_FILE
		ifs >> r >> c;
#else
		std::cin >> r >> c;
#endif
		chess_board.set(c, r);
		//chess_board.print_board();
		//chess_board.print_is_covered_board();
	}

	dfs(chess_board, k);
	result.print_board();
	return 0;
}


Measured memory_bytes: 3172