////////////////////////////////////////
//ALDS1_12_B:   Single Source Shortest Path I
//ALDS1_12_C:   Single Source Shortest Path II
//priority_queue????????¨??????????£?????????´??????1?????????????´????????£?????????????????????????
//??¨?????£????????£?????????MLE???????????????
//???????????????adjacencyMatrix[][]?????§???????????????????????¨?????????
//vector??§adjacencyList??§????£???????????????????????????¨?????¢??????????????????????????????
////////////////////////////////////////

#include <iostream>
#include <algorithm> // next_permutation
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstring> //memcpy
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate
//#include <unordered_map> //hash func.
#include <fstream> //ifstream, ofstream

//#define NDEBUG //If NDEBUG is defined before #include <cassert>, assert will be ignored. You had better define NDEBUG when u submit the code.
#include <cassert> //assert


using namespace std;

#define TEST //*******************************************************************************************************************************************
//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
//??????????????????????????????????????????????????????????§?CPU???????£??????????????????§???TLE?????????????????????????????????????????§????????¨???                           ????????????????????????cerr????????£????????????????????????????????????
#ifdef TEST
#define dout cout
#define din cin
#else
stringstream dummy; //???????????°??????dout?????????????????????????????????
#define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
//???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif

//If u wanna output to a text file instead of standard output, plz define OUTPUTFILE.
//#define OUTPUTFILE "output.txt" //*******************************************************************************************************************************************
#ifdef OUTPUTFILE
#define dout outputfile //??¨????????????TLE????????§?????????dout?????¨??¨??????????????¢????????????????????????????????????????????§????¨????????????´??????????????£??????????????????????¨?????????????????????????????????????????????§?????????????????????
ofstream outputfile(OUTPUTFILE);
#define OutputFilePath "/Users/Nag/Documents/Prgm/Test/DerivedData/Test/Build/Products/Debug/output.txt"
#endif

//If u wanna input from a text file instead of standard input, plz define INPUTFROMTEXTFILE???.
//#define INPUTFILE "input.txt" //*******************************************************************************************************************************************
#ifdef INPUTFILE
#define din inputfile
ifstream inputfile(INPUTFILE);
#endif


#define disp(A) dout << #A << " = " << setw(3) << (A) << endl
#define disP(A) dout << setw(3) << (A) << " "
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define dispAll(A,n) dout << #A << " = "; rep(j, 0, (n)) {disP(A[j]);} dout << endl

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;


const int INF = 2e9-1;
const ll INF_LL = 1e18; //Be careful for overflow.
const int NONE = -1;

#define N_MAX 10000 //num of vertex
#define M_MAX 10000 //num of edge

int N;

int chessBoard[8][8] = {0};
char charTable[10] = {0};


void display(int board[8][8]) {
    rep(i,0,8) {
        rep(j,0,8) {
            dout << charTable[ board[i][j] ];
        }
        dout << endl;
    }
    //dout << endl;
}


bool placeQueen(int r, int c, int board[8][8]) {
    
    //r check
    rep(i,0,8) {
        if(board[r][i]==1) return false;
        board[r][i]=9;
    }
    
    //c check
    rep(i,0,8) {
        if(board[i][c]==1) return false;
        board[i][c]=9;
    }
    
    //diagonal check (left-up direction)
    int rr = r-1;
    int cc = c-1;
    while(rr>=0 && cc>=0) {
        if(board[rr][cc]==1) return false;
        board[rr][cc]=9;
        rr--; cc--;
    }
    
    //diagonal check (left-down direction)
    rr = r+1;
    cc = c-1;
    while(rr<8 && cc>=0) {
        if(board[rr][cc]==1) return false;
        board[rr][cc]=9;
        rr++; cc--;
    }
    
    //diagonal check (right-up direction)
    rr = r-1;
    cc = c+1;
    while(rr>=0 && cc<8) {
        if(board[rr][cc]==1) return false;
        board[rr][cc]=9;
        rr--; cc++;
    }
    
    //diagonal check (right-down direction)
    rr = r+1;
    cc = c+1;
    while(rr<8 && cc<8) {
        if(board[rr][cc]==1) return false;
        board[rr][cc]=9;
        rr++; cc++;
    }

    //passed all check
    board[r][c]=1;
    
    return true;
}


bool solve(int board[8][8]) {
    
    int i, j;
    
    //Q?????????????????¢???
    for(i=0; i<8; i++) {
        for(j=0; j<8; j++) {
            if(board[i][j] == 1) break;
        }
        if(j==8) break; //????????????Q???????????£???
    }
    
    if(i==8) return true; //??¨??????????????????????????¨???????????¨????????§???Q??????????????????????????¨??????????????????????????????????§£????????????

    //Q?????????i?????????????????????Q????????????????£???°???????????????Q?????????????????????????????????
    for(j=0; j<8; j++) {
        int board_copy[8][8];
        memcpy(board_copy, board, sizeof(board_copy)); //??????????????????????????¶???????????????????????¢??????????????????
        
        if(board[i][j] == 0) {
            placeQueen(i, j, board);
            bool result = solve(board);
            if(result) return true;
            else {
                memcpy(board, board_copy, sizeof(board_copy)); //???????????£?????´?????????????????¢??????????????¬????????¢??????
            }
        }
    }
    
    //???????????§??\???(j==8)??¨???????????¨??????i?????????Q????????????????????¨?????§???????????£?????¨???????????¨????????§???
    return false;
}



int main() {
    charTable[0] = 'o'; //Q???????????§??????????£???????
    charTable[9] = '.'; //Q????????????????????????????????????
    charTable[1] = 'Q';
    
    
    
    din >> N;
    
    int r, c;
    rep(i,0,N) {
        din >> r >> c;
        placeQueen(r, c, chessBoard);
//        display(chessBoard);
    }
    
    solve(chessBoard);
    display(chessBoard);
    
    
    
    
    
    
#ifdef INPUTFILE
    inputfile.close();
#endif
    
#ifdef OUTPUTFILE
    outputfile.close();
    cout << "\"" << OutputFilePath << "\"" << endl;
#endif
    
    return 0;
}

Measured memory_bytes: 3108