row = [True] * 8

col = [True] * 8

dpos = [True] * 15

dneg = [True] * 15





board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)]



import sys



file_input = sys.stdin



k = int(file_input.readline())



for line in file_input:

    r, c = map(int, line.split())

    row[r] = "INIT"

    col[c] = "INIT"

    dpos[r + c] = False

    dneg[r + (7 - c)] = False

    board[r][c] = 'Q'



def dfs(i = 0):

    if i == 8:

        for line in board:

            print(*line, sep='')

        return

    if row[i] == "INIT":

        dfs(i + 1)

    elif row[i]:

        for j in range(8):

            if col[j] == "INIT":

                pass

            elif col[j] and dpos[i + j] and dneg[i + (7 - j)]:

                row[i] = False

                col[j] = False

                dpos[i + j] = False

                dneg[i + (7 - j)] = False

                board[i][j] = 'Q'

                dfs(i + 1)

                row[i] = True

                col[j] = True

                dpos[i + j] = True

                dneg[i + (7 - j)] = True

                board[i][j] = '.'



dfs()

row = [False] * 8

col = [False] * 8

dpos = [False] * 15

dneg = [False] * 15





board = [['.', '.', '.', '.', '.', '.', '.', '.'] for i in range(8)]



import sys



file_input = sys.stdin



k = int(file_input.readline())



for line in file_input:

    r, c = list(map(int, line.split()))

    row[r] = True

    col[c] = True

    dpos[r + c] = True

    dneg[r - c + 7] = True

    board[r][c] = 'Q'



def dfs(i = 0):

    if i == 8:

        for line in board:

            print((''.join(line)))

    elif row[i]:

        dfs(i + 1)

    else:

        for j in range(8):

            if col[j] or dpos[i + j] or dneg[i - j + 7]:

                continue

            row[i] = True

            col[j] = True

            dpos[i + j] = True

            dneg[i - j + 7] = True

            board[i][j] = 'Q'

            dfs(i + 1)

            row[i] = False

            col[j] = False

            dpos[i + j] = False

            dneg[i - j + 7] = False

            board[i][j] = '.'



dfs()

row = [True] * 8
col = [True] * 8
dpos = [True] * 15
dneg = [True] * 15
board = [[".", ".", ".", ".", ".", ".", ".", "."] for i in range(8)]
import sys

file_input = sys.stdin
k = int(file_input.readline())
for line in file_input:
    r, c = map(int, line.split())
    row[r] = "INIT"
    col[c] = "INIT"
    dpos[r + c] = False
    dneg[r + (7 - c)] = False
    board[r][c] = "Q"


def dfs(i=0):
    if i == 8:
        for line in board:
            print(*line, sep="")
        return
    if row[i] == "INIT":
        dfs(i + 1)
    elif row[i]:
        for j in range(8):
            if col[j] == "INIT":
                pass
            elif col[j] and dpos[i + j] and dneg[i + (7 - j)]:
                row[i] = False
                col[j] = False
                dpos[i + j] = False
                dneg[i + (7 - j)] = False
                board[i][j] = "Q"
                dfs(i + 1)
                row[i] = True
                col[j] = True
                dpos[i + j] = True
                dneg[i + (7 - j)] = True
                board[i][j] = "."


dfs()

row = [False] * 8
col = [False] * 8
dpos = [False] * 15
dneg = [False] * 15
board = [[".", ".", ".", ".", ".", ".", ".", "."] for i in range(8)]
import sys

file_input = sys.stdin
k = int(file_input.readline())
for line in file_input:
    r, c = list(map(int, line.split()))
    row[r] = True
    col[c] = True
    dpos[r + c] = True
    dneg[r - c + 7] = True
    board[r][c] = "Q"


def dfs(i=0):
    if i == 8:
        for line in board:
            print(("".join(line)))
    elif row[i]:
        dfs(i + 1)
    else:
        for j in range(8):
            if col[j] or dpos[i + j] or dneg[i - j + 7]:
                continue
            row[i] = True
            col[j] = True
            dpos[i + j] = True
            dneg[i - j + 7] = True
            board[i][j] = "Q"
            dfs(i + 1)
            row[i] = False
            col[j] = False
            dpos[i + j] = False
            dneg[i - j + 7] = False
            board[i][j] = "."


dfs()

-row = [True] * 8 -col = [True] * 8 -dpos = [True] * 15 -dneg = [True] * 15 +row = [False] * 8 +col = [False] * 8 +dpos = [False] * 15 +dneg = [False] * 15 -    r, c = map(int, line.split()) -    row[r] = "INIT" -    col[c] = "INIT" -    dpos[r + c] = False -    dneg[r + (7 - c)] = False +    r, c = list(map(int, line.split())) +    row[r] = True +    col[c] = True +    dpos[r + c] = True +    dneg[r - c + 7] = True -            print(*line, sep="") -        return -    if row[i] == "INIT": +            print(("".join(line))) +    elif row[i]: -    elif row[i]: +    else: -            if col[j] == "INIT": -                pass -            elif col[j] and dpos[i + j] and dneg[i + (7 - j)]: -                row[i] = False -                col[j] = False -                dpos[i + j] = False -                dneg[i + (7 - j)] = False -                board[i][j] = "Q" -                dfs(i + 1) -                row[i] = True -                col[j] = True -                dpos[i + j] = True -                dneg[i + (7 - j)] = True -                board[i][j] = "." +            if col[j] or dpos[i + j] or dneg[i - j + 7]: +                continue +            row[i] = True +            col[j] = True +            dpos[i + j] = True +            dneg[i - j + 7] = True +            board[i][j] = "Q" +            dfs(i + 1) +            row[i] = False +            col[j] = False +            dpos[i + j] = False +            dneg[i - j + 7] = False +            board[i][j] = "."