var board = [];




var dx = [1,1,1,0,0,-1,-1,-1];
var dy = [1,0,-1,1,-1,1,0,-1];


function check(x,y){
    var rx = x,ry = y;

    for(var i = 0;i < 8;i++){
        x = rx + dx[i];y = ry + dy[i];
        while(x >= 0 && x < 8 && y >= 0 && y < 8){
            if(board[x][y])
                return false;
            x += dx[i];y += dy[i];
        }
    }
    return true;
}

function eightqueens(row){

    if(row >= 8){
        for(var i = 0;i < 8;i++){
            var s = "";
            for(var j = 0;j < 8;j++)
                if(board[i][j])
                    s += "Q";
                else
                    s += ".";
            console.log(s);
        }
        return; 
    }
    var k = 0;
    for(;k < 8;k++){
        if(board[k][row])
            break;
    }
    if(k < 8){
        eightqueens(row + 1);
    }
    else{
        for(var i = 0;i < 8;i++){
            if(check(i,row)){
                board[i][row] = true;
                eightqueens(row + 1);
                board[i][row] = false;
            }
        }
    }
}

function Main(input){
    input = input.split("\n");

    for(var i = 0;i < 8;i++){
        board[i] = new Array(8);
        for(j = 0;j < 8;j++)
            board[i][j] = false;
    }
    
    var k = parseInt(input[0],10);

    for(var i = 1;i <= k;i++){
        input[i] = input[i].split(" ");
        var a = parseInt(input[i][0],10);var b = parseInt(input[i][1],10);
        board[a][b] = true;
    }

    eightqueens(0);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));