macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    k: usize,
    rc: [(usize, usize); k]
    }
    let mut case = (0..8).collect::<Vec<usize>>();
    let mut ans = Vec::new();
    while case.next_permutation() {
        let mut t = vec![vec!['.'; 8]; 8];
        for i in 0..8 {
            t[i][case[i]] = 'Q'
        }
        let mut f = false;
        for &i in &rc {
            if t[i.0][i.1] != 'Q' {
                f = true;
                break;
            };
        }
        if f { continue; };
        for i in 0..8 {
            let mut d = 0;
            let mut cnts = vec![0; 4];
            while i + d < 8 {
                if t[i + d][d] == 'Q' {
                    cnts[0] += 1;
                }
                if t[d][i + d] == 'Q' {
                    cnts[1] += 1;
                }
                if t[d][7 - (i + d)] == 'Q' {
                    cnts[2] += 1;
                }
                if t[i + d][7 - d] == 'Q' {
                    cnts[3] += 1;
                }
                d += 1;
            }
            if cnts.iter().any(|&x| x > 1) {
                f = true;
                break;
            }
        }
        if f { continue; };
        ans = t;
    }
    for i in ans {
        for j in i {
            print!("{}", j)
        }
        print!("\n");
    }
}

pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}

impl<T> LexicalPermutation for [T] where T: Ord {
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }

    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 { return false; }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}




Measured memory_bytes: 5048