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;
#include<cstdio>

#define SIZE 8
int q[SIZE], x[SIZE], data;

bool can_set(int n, int j)
{
    if(n == 0) return true;
    for(int i = 0; i < n; i++){
        if(q[x[i]] == j || x[i] + q[x[i]] == x[n] + j || x[i] - q[x[i]] == x[n] - j){ return false; }
	}
    return true;
}

bool set_queen()
{
    int n, j, s;
    n = data, s = 0;
    while((n < SIZE) && (n >= 0)){
        for(j = s; j < SIZE; j++){
            if(can_set(n, j)){
                q[x[n]] = j; n++; s = 0; break;
            }
        }
        if(j == SIZE){ n--; if(n >= 0){ s = q[x[n]] + 1; } }
    };
    if(n == SIZE) return true;
    return false;
}

void show_queen()
{
    for(int i = 0; i < SIZE; i++){
        for(int j = 0; j < SIZE; j++){
            (q[i] == j ? printf("Q") : printf(".") );
        }
        printf("\n");
    }
}

int main()
{
    scanf("%d", &data);
    int i, j;
    int a = (1 << 8) - 1;

    for(int k = 0; k < data; k++){
        scanf("%d %d", &i, &j);
        x[k] = i; a = a & ~(1 << i); q[i] = j; }
    i = 0;
    for(int k = 0; k < SIZE; k++){
        if(!!(a & (1 << k))){
            x[data + i] = k; i++; }
    }

    if(set_queen()) show_queen();
    return 0;
}