def solve(brd, bits)
  if bits == (1<<8) - 1
    brd.map{ |arr| puts arr.map{ |v| v ? '.' : 'Q' }.join }
    return true
  end
  y = (0..7).to_a.index{ |i| bits & (1<<i) == 0 }
  (0..7).each do |x|
    if brd[y][x] && check(y, x, brd)
      brd[y][x] = false
      bits += 1<<y
      return true if solve(brd, bits)
      bits -= 1<<y
      brd[y][x] = true
    end
  end
  false
end

def check(y, x, brd)
  (1..7).each do |i|
    [-1, 1].each do |dy|
      (-1..1).each do |dx|
        ny = y + dy * i
        nx = x + dx * i
        if 0 <= ny && ny < 8 && 0 <= nx && nx < 8
          return false unless brd[ny][nx]
        end
      end
    end
  end
  true
end

brd = 8.times.map{ [true] * 8 }
bit = 0
gets.to_i.times do
  r, c = gets.split.map(&:to_i)
  bit += 1<<r
  brd[r][c] = false
end

solve(brd, bit)