def solve(brd, bits)
  if bits == (1<<8) - 1
    brd.map{ |bs| puts bs.map{ |b| b ? '.' : 'Q' }.join }
    return
  end
  y = -1
  (0..7).each do |i|
    if (bits & (1<<i)) == 0
      y = i
      break
    end
  end
  (0..7).each do |x|
    if brd[y][x] && check(y, x, brd)
      brd[y][x] = false
      bits += 1<<y
      solve(brd, bits)
      bits -= 1<<y
      brd[y][x] = true
    end
  end
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)