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>
#define LRN 15

using namespace std;

bool row[8];   //hang
bool line[8];  //lie
bool ln[15];
bool rn[15];
int loc[8];

void show(){
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            if(j==loc[i]) cout<<'Q';
            else cout<<'.';
        }
        cout<<endl;
    }
}

void dfs(int r){
    if(r>=8){
        show();
        return;
    }
    if(row[r]){
        dfs(r+1);
        return;
    }
    for(int i=0;i<8;i++){
        if(!line[i] && !ln[r-i+7] && !rn[r+i]){
            line[i]=ln[r-i+7]=rn[r+i]=true;
            loc[r]=i;
            dfs(r+1);
            line[i]=ln[r-i+7]=rn[r+i]=false;
        }
    }
}

void init(){
    int n,a,b;

    for(int i=0;i<8;i++){
        row[i]=false;
        line[i]=false;
        for(int j=0;j<8;j++) loc[i]=-1;
    }
    for(int i=0;i<15;i++){
        ln[i]=rn[i]=false;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        loc[a]=b;
        row[a]=line[b]=true;
        ln[a-b+7]=rn[a+b]=true;
    }

}

int main(){
    init();
    dfs(0);
    return 0;
}

