import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int K;
    scan(K);
    int N = 8;
    auto s = new int[](N);
    s[] = -1;
    foreach (i ; 0 .. K) {
        int ri, ci;
        scan(ri, ci);
        s[ri] = ci;
    }

    auto p = iota(N).array;

    do {
        if (iota(N).filter!(i => s[i] != -1).any!(i => s[i] != p[i])) continue;

        auto ng = new bool[][](N, N);
        bool ok = true;

        foreach (i ; 0 .. N) {
            int r = i, c = p[i];
            if (ng[r][c]) {
                ok = false;
                break;
            }
            foreach (ii ; 1 ..  N - i) {
                if (c + ii < N) {
                    ng[r + ii][c + ii] = true;
                }
                if (c - ii >= 0) {
                    ng[r + ii][c - ii] = true;
                }
            }
        }

        debug {
            writefln("%(%s\n%)", ng);
        }

        if (ok) {
            auto ans = new char[][](N, N);
            fillAll(ans, '.');
            foreach (i ; 0 .. N) {
                ans[i][p[i]] = 'Q';
            }
            writefln("%-(%s\n%)", ans);
            return;
        }

    } while (nextPermutation(p));
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

