"""simple docstring"""







import math







class        UpperCamelCase		:
   def __init__(			self     ,__UpperCamelCase=0			)	->      Dict:  # a graph with Node 0,1,...,N-1


        '''simple docstring'''


        lowercase_	:				Dict													=	n
        lowercase_	:				int													=	[
            [math.inf for j in range(0     ,__UpperCamelCase			)] for i in range(0     ,__UpperCamelCase			)
        ]  # adjacency matrix for weight
        lowercase_	:				Dict													=	[
            [math.inf for j in range(0     ,__UpperCamelCase			)] for i in range(0     ,__UpperCamelCase			)
        ]  # dp[i][j] stores minimum distance from i to j
   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase     ,__UpperCamelCase     ,__UpperCamelCase			)	->      Optional[int]:


        '''simple docstring'''


        lowercase_	:				Union[str, Any]													=	w
   def 			_UpperCAmelCase   (			self			)	->      Optional[int]:


        '''simple docstring'''


        for k in range(0     ,self.n			):
             for i in range(0     ,self.n			):
                  for j in range(0     ,self.n			):
                       lowercase_	:				List[Any]													=	min(self.dp[i][j]     ,self.dp[i][k] + self.dp[k][j]			)







   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase     ,__UpperCamelCase			)	->      Optional[Any]:


        '''simple docstring'''


        return self.dp[u][v]


if __name__ == "__main__":
       __SCREAMING_SNAKE_CASE    	=Graph(5)
       graph.add_edge(0, 2, 9)
       graph.add_edge(0, 4, 10)
       graph.add_edge(1, 3, 5)
       graph.add_edge(2, 3, 7)
       graph.add_edge(3, 0, 10)
       graph.add_edge(3, 1, 2)
       graph.add_edge(3, 2, 1)
       graph.add_edge(3, 4, 6)
       graph.add_edge(4, 1, 3)
       graph.add_edge(4, 2, 4)
       graph.add_edge(4, 3, 9)
       graph.floyd_warshall()
       graph.show_min(1, 4)
       graph.show_min(0, 3)


"""simple docstring"""







from __future__ import annotations

__SCREAMING_SNAKE_CASE    	=[]



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



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     list[list[int]]     ,			__SCREAMING_SNAKE_CASE							:     int      ):
     if row >= len(__SCREAMING_SNAKE_CASE      ):
          solution.append(__SCREAMING_SNAKE_CASE      )
          printboard(__SCREAMING_SNAKE_CASE      )
          print()
          return True
     for i in range(len(__SCREAMING_SNAKE_CASE      )      ):
          if is_safe(__SCREAMING_SNAKE_CASE     ,			__SCREAMING_SNAKE_CASE     ,			__SCREAMING_SNAKE_CASE      ):
               lowercase_	:				int													=	1
               solve(__SCREAMING_SNAKE_CASE     ,			row + 1      )
               lowercase_	:				Dict													=	0
     return False



def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     list[list[int]]      ):
     for i in range(len(__SCREAMING_SNAKE_CASE      )      ):
          for j in range(len(__SCREAMING_SNAKE_CASE      )      ):
               if board[i][j] == 1:
                    print('Q'     ,			end=' '      )
               else:
                    print('.'     ,			end=' '      )
          print()


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







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

