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...
# 8 Queens Problem

import sys, itertools
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

board = [["."]*8 for _ in range(8)]

def diagonal_positions(Q):
    output = set()
    output.add(Q)
    for i in range(8):
        output.add((Q[0] + i, Q[1] + i))
        output.add((Q[0] + i, Q[1] - i))
        output.add((Q[0] - i, Q[1] + i))
        output.add((Q[0] - i, Q[1] - i))
    return output

k = int(input())
row_indices = set(range(8))
col_indices = set(range(8))
Q_positions = set()
NG_positions = set()

for _ in range(k):
    r, c = map(int, input().split())
    row_indices.discard(r)
    col_indices.discard(c)
    Q_positions.add((r,c))
    NG_positions |= diagonal_positions((r,c))

for rows in list(itertools.permutations(row_indices)):
    for cols in list(itertools.permutations(col_indices)):
        Q_positions_tmp = Q_positions.copy()
        NG_positions_tmp = NG_positions.copy()
        putting_Q = set((rows[i], cols[i]) for i in range(8-k))

        for new_Q in putting_Q:
            if new_Q in NG_positions_tmp:
                break
            else:
                Q_positions_tmp.add(new_Q)
                NG_positions_tmp |= diagonal_positions(new_Q)
        else:
            for q in Q_positions_tmp:
                board[q[0]][q[1]] = "Q"
            for i in range(8):
                print("".join(board[i]))
            exit()
