output_description: Print a $8 \times 8$ chess board by strings where a square with a queen is
  represented by 'Q' and an empty square is represented by '.'.
input_description: In the first line, an integer $k$ is given. In the following $k$ lines, each
  square where a queen is already placed is given by two integers $r$ and $c$.
  $r$ and $c$ respectively denotes the row number and the column number. The
  row/column numbers start with 0.
attempt: def sakuzyo(i):
      if koteirow[i] == 1:
          sakuzyo(i - 1)
      else:
          for j in range(N):
              if haiti[i][j] == "Q":
                  # print('delete {} {}'.format(i, j))
                  haiti[i][j] = "."
                  row[i] = 0
                  col[j] = 0
                  dpos[i + j] = 0
                  dneg[i - j + (N - 1)] = 0
                  if j == N - 1:
                      sakuzyo(i - 1)
                  else:
                      sounyuu(i, j + 1)
  
  
  def sounyuu(i, j):
      if koteirow[i] == 0:
          for k in range(j, N):
              flag = 0
              if col[k] == 0 and dpos[i + k] == 0 and dneg[i - k + (N - 1)] == 0:
                  haiti[i][k] = "Q"
                  # print('add {} {}'.format(i, k))
                  row[i] = 1
                  col[k] = 1
                  dpos[i + k] = 1
                  dneg[i - k + (N - 1)] = 1
                  flag = 1
                  if i == N - 1:
                      for o in range(N):
                          for p in range(N):
                              print(haiti[o][p], end="")
                          print()
                      exit()
                  else:
                      sounyuu(i + 1, 0)
          if flag == 0:
              sakuzyo(i - 1)
      elif i == N - 1:
          for o in range(N):
              for p in range(N):
                  print(haiti[o][p], end="")
              print()
          exit()
      else:
          sounyuu(i + 1, j)
  
  
  k = int(input())
  data = [list(map(int, input().split())) for _ in range(k)]
  
  N = 8
  row = [0] * N
  col = [0] * N
  dpos = [0] * (N * 2 - 1)
  dneg = [0] * (N * 2 - 1)
  haiti = [["."] * N for _ in range(N)]
  koteirow = [0] * N
  
  for i in data:
      haiti[i[0]][i[1]] = "Q"
      row[i[0]] = 1
      col[i[1]] = 1
      dpos[i[0] + i[1]] = 1
      dneg[i[0] - i[1] + (N - 1)] = 1
      koteirow[i[0]] = 1
  
  sounyuu(0, 0)
  
problem_description: 8 Queens Problem
  
  The goal of 8 Queens Problem is to put eight queens on a chess-board such that
  none of them threatens any of others. A queen threatens the squares in the
  same row, in the same column, or on the same diagonals as shown in the
  following figure.
  
  ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_ALDS1_13_A_8queens)  
  
  For a given chess board where $k$ queens are already placed, find the solution
  of the 8 queens problem.
samples: [{"input": "2\n    2 2\n    5 3", "output": "......Q.\n    Q.......\n    ..Q.....\n    .......Q\n    .....Q..\n    ...Q....\n    .Q......\n    ....Q..."}]