The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure.

<image>


For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.

Constraints

* There is exactly one solution

Input

In the first line, an integer $k$ is given. In the following $k$ lines, each square where a queen is already placed is given by two integers $r$ and $c$. $r$ and $c$ respectively denotes the row number and the column number. The row/column numbers start with 0.

Output

Print a $8 \times 8$ chess board by strings where a square with a queen is represented by 'Q' and an empty square is represented by '.'.

Example

Input

2
2 2
5 3


Output

......Q.
Q.......
..Q.....
.......Q
.....Q..
...Q....
.Q......
....Q...
#include<iostream>
using namespace std;

const int D_y[8] = { -1,-1,0,1,1,1,0,-1 };
const int D_x[8] = { 0,1,1,1,0,-1,-1,-1 };

void checkRange(int board[8][8], int X, int Y,int n) {
	board[Y][X] += n;
	for (int i = 0; i < 8; i++) {
		int x = X + D_x[i];
		int y = Y + D_y[i];
		while (x >= 0 && x < 8 && y >= 0 && y < 8) {
			board[y][x] += n;
			x += D_x[i];
			y += D_y[i];
		}
	}
}

bool solve(bool Qboard[8][8], int board[8][8], int n) {
	if (n == 0)return true;
	bool copyBoard[8][8];

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (board[i][j] == 0) {

				Qboard[i][j] = true;
				checkRange(board, j, i, 1);

				if (solve(Qboard, board, n - 1))return true;

				Qboard[i][j] = false;
				checkRange(board, j, i, -1);
			}
		}
	}
	return false;
}

int main() {
	int k;
	int board[8][8] = { 0 };
	bool Qboard[8][8] = { false };

	cin >> k;
	for (int i = 0; i < k; i++) {
		int r, c;
		cin >> r >> c;
		Qboard[r][c] = true;
		checkRange(board, c, r, 1);
	}

	solve(Qboard, board, 8 - k);

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if (Qboard[i][j])cout << "Q";
			else cout << ".";
		}
		cout << endl;
	}

	return 0;
}