#include <bits/stdc++.h>
using namespace std;

int  Quinn(int x,int y,char chess_bord[8][8]){
    if(chess_bord[x][y] == 'Q')  return 1;
    if(chess_bord[x][y] == '-')  return -1;

    chess_bord[x][y] = 'Q';

    for(int i = 0; i < x; i++){

        if(chess_bord[i][y] =='Q')  return -1;

        chess_bord[i][y] ='-';

    }

    for(int i = x + 1; i < 8; i++){
        if(chess_bord[i][y] == 'Q')  return -1;

        chess_bord[i][y] = '-';

    }

    for(int i = 0; i < y; i++){

        if(chess_bord[x][i] == 'Q')  return -1;

        chess_bord[x][i] = '-';

    }

    for(int i = y + 1; i < 8; i++){

        if(chess_bord[x][i] == 'Q')  return -1;

        chess_bord[x][i] = '-';
    }

    int loop=1;

    while(1){//左斜め上を埋める

        if(x - loop < 0 || y - loop < 0 ){
            break;
        }

        if(chess_bord[x - loop][y - loop] == 'Q')  return -1;

        chess_bord[x - loop][y - loop] = '-';

        loop++;
    }

    loop=1;

    while(1){//左斜め下を埋める

        if(x - loop < 0 || y + loop > 7 ) {
            break;
        }    

        if(chess_bord[x - loop][y + loop] == 'Q')  return -1;

        chess_bord[x - loop][y + loop] = '-';

        loop++;
    }


    loop=1;


    while(1){//右斜め上を埋める
    
        if(x + loop > 7 || y - loop < 0 ) {
            break;
        }    

        if(chess_bord[x + loop][y - loop] == 'Q')  return -1;

        chess_bord[x + loop][y - loop] = '-';

        loop++;
    }

    loop=1;

    while(1){//右斜め下を埋める

        if(x + loop > 7 || y + loop > 7 ){
            break;
        }    

        if(chess_bord[x + loop][y + loop] == 'Q')  return -1;

        chess_bord[x + loop][y + loop] = '-';

        loop++;
    }

    return 1;

}

int main(){
    int num = 0 ;
    int count = 0;
    char chess_bord[8][8];
    char tmp_chess_bord[8][8];
    cin >> num;
    count = num;

    for(int i= 0; i < 8; i++){

        for(int j = 0 ; j < 8; j++){

            chess_bord[i][j] = '.';

        }
    }

    for(int i = 0; i < num ; i++){
        int tmp_x,tmp_y;
        cin >> tmp_x >> tmp_y;
        Quinn(tmp_x,tmp_y,chess_bord);
    }

    memcpy(tmp_chess_bord, chess_bord, sizeof(chess_bord));
    int flag=0;
    
    for(int i = 0; i < 8; i++){
        if(chess_bord[0][i] != '.' && chess_bord[0][i] != 'Q')  continue;
        for(int j = 0; j < 8; j++){
            if(chess_bord[1][j] != '.' && chess_bord[1][j] != 'Q')  continue;
            for(int k = 0; k < 8; k++){
                if(chess_bord[2][k] != '.' && chess_bord[2][k] != 'Q')  continue;
                for(int l = 0; l < 8; l++ ){
                    if(chess_bord[3][l] != '.' && chess_bord[3][l] != 'Q' )  continue;
                    for(int m = 0; m < 8; m++){
                        if(chess_bord[4][m] != '.' && chess_bord[4][m] != 'Q' )  continue;
                        for(int n = 0; n < 8; n++){
                           if(chess_bord[5][n] != '.' && chess_bord[5][n] != 'Q')  continue;
                            for(int p = 0; p < 8; p++){
                                if(chess_bord[6][p] != '.' && chess_bord[6][p] != 'Q')  continue;
                                for(int q = 0; q < 8; q++){
                                    if(chess_bord[7][q] != '.' && chess_bord[7][q] != 'Q')  continue;

                                    if(Quinn(0,i,tmp_chess_bord) == 1 && Quinn(1,j,tmp_chess_bord) ==1 && Quinn(2,k,tmp_chess_bord) ==1 && Quinn(3,l,tmp_chess_bord) ==1 && Quinn(4,m,tmp_chess_bord) ==1 && 
                                    Quinn(5,n,tmp_chess_bord) == 1 && Quinn(6,p,tmp_chess_bord) == 1 && Quinn(7,q,tmp_chess_bord) ==1){
                                            memcpy(chess_bord, tmp_chess_bord, sizeof(chess_bord));
                                            for(int i= 0; i < 8; i++){

                                                for(int j = 0 ; j < 8; j++){

                                                    if(chess_bord[i][j] == '-') chess_bord[i][j] = '.';
                                                        cout<<chess_bord[i][j];

                                                }
                                                cout<<endl;
                                            }

                                    }else{
                                        memcpy(tmp_chess_bord, chess_bord, sizeof(chess_bord));
                                    }

                                }

                            }

                        }
                    }
                }
            }
        }
    }    
}


Measured memory_bytes: 3096