import itertools

N, Q, row, col = eval(input()), [], 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 not any(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) for r1, c1 in queen):

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

        break
import itertools

N, Q, row, col = eval(input()), [], 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 not 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 for r1, c1 in queen):

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

        break
import itertools

N, Q, row, col = eval(input()), [], 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 not any(
        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
        )
        for r1, c1 in queen
    ):
        print(
            "\n".join(
                "".join("Q" if (r, c) in queen else "." for c in range(8))
                for r in range(8)
            )
        )
        break

import itertools

N, Q, row, col = eval(input()), [], 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 not 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
        for r1, c1 in queen
    ):
        print(
            "\n".join(
                "".join("Q" if (r, c) in queen else "." for c in range(8))
                for r in range(8)
            )
        )
        break

-        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 -        ) +        (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