K = gets.chomp.to_i
rc = []
K.times do |i|
  rc[i] = gets.chomp.split.map(&:to_i)
end

(0..7).to_a.permutation(8) do |arr|
  flag = false
  rc.each do |ar|
    r,c = ar
    unless arr[r] == c
      flag = true
      break
    end
  end
  next if flag

  (0..7).to_a.combination(2) do |ar|
    r1,r2 = ar
    if (arr[r1] - arr[r2]).abs == (r1 - r2).abs
      flag = true
      break
    end
  end
  next if flag

  8.times do |i|
    ar = []
    8.times do |j|
      if arr[i] == j
        ar.push('Q')
      else
        ar.push('.')
      end
    end
    puts ar.join('')
  end
end

