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...
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int already_n = Integer.parseInt(sc.next());
        boolean[][] board = new boolean[8][8];
    	for(int i=0; i<8; i++){
    		for(int j=0; j<8; j++){
    		    board[i][j] = false;
    		}
    	}
        
        int row =0, column=0;
        for(int i=0; i<already_n; i++){
            row = Integer.parseInt(sc.next());
            column = Integer.parseInt(sc.next());
            board[row][column] = true;
        }
        
        ArrayList<boolean[][]> ans = boardAll(board, 0);
        boolean[][] new_board = new boolean[8][8];
        
        for(int i=0; i<ans.size(); i++){
                new_board = ans.get(i);
        		for(int j=0; j<8; j++){
        			for(int k=0; k<8; k++){
        			    if(new_board[j][k]) System.out.print("Q");
        			    else System.out.print(".");
        			}
        			System.out.println();
            }
        }
        
    }
    private static boolean ckConflict(boolean[][] board, int y, int x){       //true・・・ぶつかる
        int over = 0;
        for(int i=0; i<8; i++){
            if(board[i][x]) over++;
            if(over>0) return true;
        }
        over = 0;
        for(int i=0; i<8; i++){
            if(board[y][i]) over++;
            if(over>0) return true;
        }
        over = 0;
        for(int i=-8; i<8; i++){
            if(((x+i)>=0) && ((y+i)>=0) && ((x+i)<8) && ((y+i)<8)){
                if(board[y+i][x+i]) over++;
            }
            if(over>0) return true;
        }
        over = 0;
        for(int i=-8; i<8; i++){
            if(((x-i)>=0) && ((y+i)>=0) && ((x-i)<8) && ((y+i)<8)){
                if(board[y+i][x-i]) over++;
            }
            if(over>0) return true;
        }
        return false;
    }
    
    private static ArrayList<boolean[][]> boardAll(boolean[][] board, int r_now){
        ArrayList<boolean[][]> ans = new ArrayList<boolean[][]>(1);
        boolean there = false;
        boolean[][] new_board = new boolean[8][8];
        
        if(r_now==8){
            ans.add(board.clone());
            return ans;
        }
        
        for(int i=0; i<8; i++){
            if(board[r_now][i]) there=true;
        }
        if(there){
            return boardAll(board, r_now+1);
        }else{
            for(int i=0; i<8; i++){
                if(!ckConflict(board, r_now, i)){
                    for(int j=0; j<8; j++){ new_board[j] = board[j].clone(); }
                    new_board[r_now][i] = true;
                    ans.addAll(boardAll(new_board, r_now+1));
                }
            }
            return ans;
        }
    }
}
