package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	k := getNextInt(scanner)
	kk := map[int]int{}
	for i := 0; i < k; i++ {
		r := getNextInt(scanner)
		c := getNextInt(scanner)
		kk[r] = c + 1
	}
	f := factorial{}
	f.init(8)
	for i := 0; i < f.fac[7]*8; i++ {
		p := f.get(i)
		valid := true
		for j := 0; valid && j < 8; j++ {
			if kk[j] == 0 {
				continue
			}
			if kk[j] == p[j] {
				continue
			}
			valid = false
		}
		if valid == false {
			continue
		}

		for ii := 0; ii < 8; ii++ {
			for j := 0; j < ii; j++ {
				valid = valid && ok(ii, p[ii]-1, j, p[j]-1)
			}
		}
		if valid == false {
			continue
		}

		for r := 0; r < 8; r++ {
			for c := 0; c < 8; c++ {
				if p[r] == c+1 {
					fmt.Fprint(writer, "Q")
					continue
				}
				fmt.Fprint(writer, ".")
			}
			fmt.Fprintln(writer, "")
		}
		return
	}
}

func ok(r, c, r2, c2 int) bool {
	if r == r2 {
		return false
	}
	if c == c2 {
		return false
	}
	if absint(r-r2) == absint(c-c2) {
		return false
	}
	return true
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type factorial struct {
	n   int
	fac []int
}

func (f *factorial) init(n int) {
	f.n = n
	f.fac = make([]int, n)
	f.fac[0] = 1
	for i := 1; i < n; i++ {
		f.fac[i] = f.fac[i-1] * i
	}
}
func (f *factorial) index(p []int) int {
	n := f.n
	ans := 0
	used := make([]bool, n)
	for i := 0; i < n; i++ {
		sum := 0
		for j := p[i] - 1; j >= 0; j-- {
			if used[j] {
				continue
			}
			sum++
		}
		used[p[i]-1] = true
		ans += sum * f.fac[n-1-i]
	}
	return ans
}
func (f *factorial) get(index int) []int {
	n := f.n
	ans := make([]int, n)
	used := make([]bool, n)
	for i := 0; i < n; i++ {
		ans[i] = index / f.fac[n-1-i]
		index %= f.fac[n-1-i]
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if used[j] {
				continue
			}
			if ans[i] == 0 {
				ans[i] = j + 1
				used[j] = true
				break
			}
			ans[i]--
		}
	}
	return ans
}



Measured memory_bytes: 3892