

"""simple docstring"""

from functools import lru_cache



@lru_cache
def       SCREAMING_SNAKE_CASE							( lowercase__   )			->						int:
 if num < 0:
  raise ValueError("Number should not be negative."   )

 return 1 if num in (0, 1) else num * factorial(num - 1   )


if __name__ == "__main__":
    import doctest

    doctest.testmod()









"""simple docstring"""

from __future__ import annotations

_UpperCamelCase		     =    []



def       SCREAMING_SNAKE_CASE							( lowercase__					,					lowercase__					,					lowercase__   )			->						bool:
 for i in range(len(lowercase__   )   ):
  if board[row][i] == 1:
   return False
 for i in range(len(lowercase__   )   ):
  if board[i][column] == 1:
   return False
 for i, j in zip(range(lowercase__					,					-1					,					-1   )					,					range(lowercase__					,					-1					,					-1   )   ):
  if board[i][j] == 1:
   return False
 for i, j in zip(range(lowercase__					,					-1					,					-1   )					,					range(lowercase__					,					len(lowercase__   )   )   ):
  if board[i][j] == 1:
   return False
 return True



def       SCREAMING_SNAKE_CASE							( lowercase__					,					lowercase__   )			->						bool:
 if row >= len(lowercase__   ):
  solution.append(lowercase__   )
  printboard(lowercase__   )
  print()
  return True
 for i in range(len(lowercase__   )   ):
  if is_safe(lowercase__					,					lowercase__					,					lowercase__   ):
   lowerCAmelCase__   :				List[Any] 			=				1
   solve(lowercase__					,					row + 1   )
   lowerCAmelCase__   :				Dict 			=				0
 return False



def       SCREAMING_SNAKE_CASE							( lowercase__   )			->						None:
 for i in range(len(lowercase__   )   ):
  for j in range(len(lowercase__   )   ):
   if board[i][j] == 1:
    print("Q"					,					end=" "   )
   else:
    print("."					,					end=" "   )
  print()


# n=int(input("The no. of queens"))
_UpperCamelCase		     =    8
_UpperCamelCase		     =    [[0 for i in range(n)] for j in range(n)]
solve(board, 0)






print("""The total no. of solutions are :""", len(solution))






