import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.range;
class State
{
    public:
    bool[] xx;
    int[] yy;
    bool[] zz;
    bool[] ww;
    Chunks!(dchar[]) board;
}
bool ad(State state, int y)
{
    if (y == 8)
    {
        for (y = 0; y < 8; y++)
        {
            for (int x = 0; x < 8; x++)
            {
                if (state.board[x][y] == 'Q')
                {
                    if (state.yy[x] != y)
                        return false;
                }
            }
        }
        return true;
    }
   for (int x = 0; x < 8; x++)
   {
       if (state.xx[x] || state.zz[x + y] || state.ww[y - x + 8 - 1])
           continue;
       state.yy[y] = x;
       state.xx[x] = true;
       state.zz[x + y] = true;
       state.ww[y - x + 8 - 1] = true;
       
       if (ad(state, y + 1))
       {
           return true;
       }
       state.ww[y - x + 8 - 1] = !true;
       state.zz[x + y] = !true;
       state.xx[x] = !true;
       state.yy[y] = 0;
   }
   return false;
}
void main()
{
    auto b = new dchar[8 * 8];
    b.fill(' ');
    State state = new State();
    state.xx = new bool[8];
    state.yy = new int[8];
    state.zz = new bool[8 * 2];
    state.ww = new bool[8 * 2];
    state.board = b.chunks(8);;
    foreach (i; iota(readln().strip.to!int))
    {
        int x, y;
        scanf("%d %d", &x, &y);
        state.board[x][y] = 'Q';
    }

    ad(state, 0);
    for (int y = 0; y < 8; y++)
    {
        for (int x = 0; x < 8; x++)
        {
            if (state.xx[x] && state.yy[y] == x)
                write('Q');
            else
                write('.');
        }
        writeln();
    }
}
