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 itertools
import copy

k = int(input())
li = [list(map(int, input().split())) for _ in range(k)]

bord = [['.']*8 for _ in range(8)]

exclude_num = []
x_list = [i for i in range(8)]
y_list = [i for i in range(8)]

def queen_move(some_list):
    for x,y in some_list:
        
        for i in range(8):
            bord[x][i] = '.'
            bord[i][y] = '.'
        
        cnt = 1    
        while True:
            if x-cnt >= 0 and y-cnt >= 0:
                bord[x-cnt][y-cnt] = '.'
            else:
                break
            cnt += 1
            
        cnt = 1    
        while True:
            if x-cnt >= 0 and y+cnt <= 7:
                bord[x-cnt][y+cnt] = '.'
            else:
                break
            cnt += 1
    
        cnt = 1    
        while True:
            if x+cnt <= 7 and y+cnt <= 7:
                bord[x+cnt][y+cnt] = '.'
            else:
                break
            cnt += 1
    
        cnt = 1    
        while True:
            if x+cnt <= 7 and y-cnt >= 0:
                bord[x+cnt][y-cnt] = '.'
            else:
                break
            cnt += 1

def check_queen(k):
    check = 0
    for i in range(8):
        for j in range(8):
            if bord[i][j] == 'Q':
                check += 1
    if check == k:
        return True
    else:
        return False

queen_move(li)
        
for x,y in li:
    bord[x][y] = 'Q'
    x_list.remove(x)
    y_list.remove(y)
    
bord_original = copy.deepcopy(bord)

for numbers in itertools.permutations(y_list, 8-k):
    cnt = 0
    bord = copy.deepcopy(bord_original)
    for number in numbers:
        tmp_li = [[x_list[cnt], number]]
        queen_move(tmp_li)
        bord[tmp_li[0][0]][tmp_li[0][1]] = 'Q'
        cnt += 1
        if check_queen(k+cnt) == False:
            break
    else:
        for ans in bord:
            print(''.join(ans))
        break

