from itertools import permutations

def check(queen):

    for r1, c1 in queen:

        if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in queen):

            return False

    return True

N = int(input())

Q, row, col = [], list(range(8)), list(range(8))

for _ in range(N):

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

    Q.append((r, c))

    row.remove(r)

    col.remove(c)

for l in permutations(col):

    queen = Q[:] + list(zip(row, l))

    if check(queen):

        board = [''.join('Q' if (r, c) in queen else '.' for c in range(8)) for r in range(8)]

        print(*board, sep='\n')

        break

import itertools

def check(q):

    for r1, c1 in q:

        if any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in q): return 0

    return 1

N = eval(input())

Q, row, col = [], list(range(8)), list(range(8))

for _ in range(N):

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

    Q.append((r, c))

    row.remove(r)

    col.remove(c)

for l in itertools.permutations(col):

    queen = Q[:] + list(zip(row, l))

    if check(queen):

        print('\n'.join([''.join('Q' if (r, c) in queen else '.' for c in range(8)) for r in range(8)]))

        break
from itertools import permutations


def check(queen):
    for r1, c1 in queen:
        if any(
            (r1 != r2 or c1 != c2)
            and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2)
            for r2, c2 in queen
        ):
            return False
    return True


N = int(input())
Q, row, col = [], list(range(8)), list(range(8))
for _ in range(N):
    r, c = map(int, input().split())
    Q.append((r, c))
    row.remove(r)
    col.remove(c)
for l in permutations(col):
    queen = Q[:] + list(zip(row, l))
    if check(queen):
        board = [
            "".join("Q" if (r, c) in queen else "." for c in range(8)) for r in range(8)
        ]
        print(*board, sep="\n")
        break

import itertools


def check(q):
    for r1, c1 in q:
        if any(
            (r1 != r2 or c1 != c2)
            and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2)
            for r2, c2 in q
        ):
            return 0
    return 1


N = eval(input())
Q, row, col = [], list(range(8)), list(range(8))
for _ in range(N):
    r, c = list(map(int, input().split()))
    Q.append((r, c))
    row.remove(r)
    col.remove(c)
for l in itertools.permutations(col):
    queen = Q[:] + list(zip(row, l))
    if check(queen):
        print(
            "\n".join(
                [
                    "".join("Q" if (r, c) in queen else "." for c in range(8))
                    for r in range(8)
                ]
            )
        )
        break

-from itertools import permutations +import itertools -def check(queen): -    for r1, c1 in queen: +def check(q): +    for r1, c1 in q: -            for r2, c2 in queen +            for r2, c2 in q -            return False -    return True +            return 0 +    return 1 -N = int(input()) +N = eval(input()) -    r, c = map(int, input().split()) +    r, c = list(map(int, input().split())) -for l in permutations(col): +for l in itertools.permutations(col): -        board = [ -            "".join("Q" if (r, c) in queen else "." for c in range(8)) for r in range(8) -        ] -        print(*board, sep="\n") +        print( +            "\n".join( +                [ +                    "".join("Q" if (r, c) in queen else "." for c in range(8)) +                    for r in range(8) +                ] +            ) +        )