object Main {
  import scala.io.StdIn.readLine
  def main(args: Array[String]):Unit =  {
    val n: Int = readLine().toInt
    val list: List[Cell] = for (_ <- (1 to n).toList) yield {
      val Array(y, x) = readLine().split(" ").map(_.toInt)
      new Cell(x, y)
    }
    val res = search(list, 8 - n).get
    print(format(sort(res)))
  }
  def format(list:List[Cell]):String = {
    list match{
      case Nil => ""
      case (cell::cr) =>
        ("." * 8 + "\n").patch(cell.x, "Q", 1) + format(cr)
    }
  }
  def simpleFormat(list:List[Cell]):String = {
    list match{
      case Nil => ""
      case h::tail =>
        h.x.toString() + "," + h.y.toString() + "\n" + simpleFormat(tail)
    }
  }
  def include(list:List[Cell], x:Int):Boolean = {
    list match{
      case Nil => false
      case (h::tail) => h.is_on_same_line(x) || include(tail, x)
    }
  }
  def include(list:List[Cell], cell:Cell):Boolean = {
    list match{
      case Nil => false
      case (h::tail) => h == cell || include(tail, cell)
    }
  }
  def find[a](f:a => Boolean, list:List[a]):Option[a] = {
    list match{
      case Nil => None
      case (h::tail) =>
        f(h) match{
          case true => Some(h)
          case _ => find(f, tail)
        }
    }
  }
  def filter[a](f:a => Boolean, list:List[a]):List[a] = {
    list match{
      case Nil => Nil
      case (h::tail) =>
        f(h) match{
          case true => h::filter(f, tail)
          case _ => filter(f, tail)
        }
    }
  }
  def map[a, b](f:a => b, list:List[a]):List[b] = {
    list match{
      case Nil => Nil
      case (h::tail) => f(h)::map(f, tail)
    }
  }
  def findSome[a](list:List[Option[a]]):Option[a] = {
    list match{
      case Nil => None
      case (h::tail) =>
        h match{
          case Some(_) => h
          case None => findSome(tail)
        }
    }
  }
  def search(list:List[Cell], num:Int):Option[List[Cell]] = {
    num match{
      case 0 => Some(list)
      case _ =>
        val culm = find(!include(list, _:Int), (0 to 7).toList)
        culm match{
          case None => None
          case Some(x) =>
            val suspect = filter(!include(list, _:Cell), map(new Cell(x, _:Int), (0 to 7).toList))
            val res = map((cell:Cell) => search(cell::list, num - 1), suspect)
            findSome(res)
        }
    }
  }
  def length[a](list:List[a]):Int = {
    list match{
      case Nil => 0
      case _::tail => 1 + length(tail)
    }
  }
  def sort[T <:Ordered[T]](list:List[T], length:Int = -1):List[T] = {
    val len = if (length == -1)
      list.length
    else
      length
    def merge[T <: Ordered[T]](left:List[T], right:List[T]):List[T] = {
      (left, right) match {
        case (Nil, _) => right
        case (_, Nil) => left
        case (l::lt, r::rt) =>
          (l < r) match {
            case true => l::merge(lt, right)
            case false => r::merge(left, rt)
          }
      }
    }
    list match{
      case Nil => Nil
      case a::Nil => list
      case _ =>
        val mid = len / 2
        val (left, right) = list.splitAt(mid)
        merge(sort(left, mid), sort(right, len - mid))
    }
  }
}
class Cell(val x:Int, val y:Int) extends Ordered[Cell] {
  def ==(other:Cell):Boolean = {
    return (x == other.x) || (y == other.y) || (x - other.x).abs == (y - other.y).abs
  }
  def is_on_same_line(other:Int):Boolean = {
    return (x == other)
  }
  def compare(that:Cell):Int = {
    y.compare(that.y)
  }
}

Measured memory_bytes: 44788